Tekblogs

MS-Excel Info

  • SECOND() function

Returns the seconds of a time value. The second is given as an integer in the range 0 (zero) to 59.

Syntax: SECOND(serial_number)

Serial_number is the time that contains the seconds you want to find. Times may be entered as text strings within quotation marks (for example, "6:45 PM"), as decimal numbers (for example, 0.78125, which represents 6:45 PM), or as results of other formulas or functions (for example, TIMEVALUE("6:45 PM")).

Example-1: If two cells A1 and A2 contain the value "4:18:18 PM" and "4:48 PM", then the "=SECOND(A1)" will return the value as 18 and "=SECOND(A2)" will return the value 0.

Example-2: Say in your D column you have a series of time values (in the form HH:MM:SS), you can get to know the difference in seconds across each cell in D column as : "=IF(D5=D4,"",SECOND(D5-D4))". It just calculates if the cells D4 and D5 are same, if so asks the IF function to leave the cell blank and if not, find out the difference of both the cells in Seconds.

  • COUNTIF() function

Counts the number of cells within a range that meet the given criteria.

Syntax: COUNTIF(range,criteria)

Range is the range of cells from which you want to count cells.

Criteria is the criteria in the form of a number, expression, cell reference, or text that defines which cells will be counted. For example, criteria can be expressed as 32, "32", ">32", "apples", or B4.

  • dfd

Getters and Setters

you have a Person object and whose size object is what you are trying to access or set.

Before the setters/getters were in picture or came into existence, the variables were declared public and given outside access without any harms.

In that case,

class Person
    {
      public int age;
 
      public static void main(String[] args) {
 
         Person myObj = new Person();
         myObj.age = 5;
         System.out.println("myObj.age : "+myObj.age);
 
         Person myObj2 = new Person();
         /* Check here! */
         myObj.age = -2; //Ouch! a syntactically correct but logically incorrect value
         System.out.println("myObj2.age : "+myObj2.age);
      }
    }

Just to have a better control on this value being accessed, there came a rescue in the form of Getters and Setters. As the name indicates, Getter is used to get/obtain a value and Setter is to set a value back. They are also called as Accessor and Mutators.

What if you allowed the access through a method and NOT directly? For which you need to have two things.

* First "protect" your variable from outside access. Means, declare them to be of private.
* Then provide getter and setter for your private variable. As the variable is pricate, the getter and setters should be public.

Following the same, the code will initially look like

class Person
    {
      private int age;
 
       /* Getter Method */
 
      public int getAge() {
        return this.age;
      }  
 
      /* Setter Method */
 
      public void setAge(int newAge) {
        this.age = newAge;
      } 
      public static void main(String[] args) {
         Person myObj = new Person();
         //myObj.age = 5; // can't access directly!
         myObj.setAge(5);
         System.out.println("myObj.age : "+myObj.getAge());
         Person myObj2 = new Person();
 
         /* Check here! */
         myObj.SetAge(-2); //Ouch! a syntactically correct but logically incorrect value
         System.out.println("myObj2.age : "+myObj2.getAge());
      }
    }

But had you been exposing your code through this way, it would be very easy in a later point when you realize that setting a negative value is a sin! you should NOT allow that!!, you have an easy way to get rid of it.

Just modify/update the setter method as below

...
      public void setAge(int newAge) {
 
       /* introducing a new check for Age */
 
        if(newAge <=0){ /*definitely age should NOT be zero! */
          System.err.println("Invalid age!");
          return;
        }
 
         this.age = newAge;
 
      }

This way, you really don't break the existing code. As such the users would still continue using your setAge() method to set an age.

Here dealing with the invalid values and the condition to confirm the same may definitely based on the user and requirement. You can either set a default value or throw an exception or just let the user know about invalid value and continue the program normally.

Java, J2EE Applications

Information about J2EE applications
==========================
J2EE stands for Java 2 Enterprise Edition, a flavour of Java language which is used for developing enterprise applications.

When you say 'enterprise' it is for a whole company/organisation wiht many feautures in mind like transactions, security, distribution, networks etc.,

J2EE is based on or running on top of J2SE (Java 2 Standard Edition) which is the core or base or actual Java language. Another flavour of Java was J2ME (Java 2 Micro Edition) which is used for developing mobile applications whereas this J2SE and J2EE are used for desktop and server applications

The names are now renamed as Java SE , Java EE and Java ME as per the latest versions.

Java - as a programming language offers many advantages especially its WORA (Write Once Run Anywhere) which is based on the 'cross platform' . That is once you develop an application the application is compatible or portable to any other platform for its execution. The competing or earlier languages (like C, C++ etc.,) were not supporting this facility and for achieving this portability they were supposed to be rewritten according to the platform being used and the appropriate tools (compiler, interpreter) facilitates the translation and execution. In case of Java due to its promise for 'cross platform' or 'platform neutral nature' there is absolutely no need
to rewrite as the structural features are promised to remain the same (the size of each data value it occupies etc.,)

Two main aspects one has to be aware of when dealing with Java applications - JDK and JRE.

JDK stands for Java Development Kit consisting of the Java APIs (Applicatoin Programming Interface) that has the Java builtin library files whcih the developers can make use of.

JRE stands for Java Runtime Environment which provides the environment to host the applications developed by using JDK.

Notes from 'Manning Web Development with JSP - 2nd Ed - PDF" book

  • JSP Page directive —> there are 12 attributes (info, language, contentType, session, autoFlush, isErrorPage, extends, import, pageEncoding, errorPage, isThreadSafe, buffer)
    • out of these 12, only import attribute can either get repeated in the same directive OR can be present multiple times in the same JSP page. Others are NOT allowed
    • Invalid or nonpresent attributes lead to a compilation error when the JSP gets translated into a Servlet
  • dfd

doubts

  • 1. Chapter 5, Page #74

You may be wondering what would happen if you tried to import two classes
that have the same base name, as in the following:

<%@ page import="java.util.List, java.awt.List" %>

The JSP container considers this to be an illegal statement, and will refuse to process
a JSP page that includes such an ambiguity. You might instead try to import these
two classes using their packages, as follows:

<%@ page import="java.util.*, java.awt.*" %>

  • 2.

Creating a table in MS-Word without using Mouse and Menus

courtesy: Vidhya R of THBS

Hi All,

Do you know its possible create Table without using mouse and menus in MS word and Outlook. Here its that…

Type the content (+——+——-+——+) in Microsoft Word, Outlook and press Enter. One row of a table will be created and for more rows you can press TAB.

Step 1:

+———–+————————+————-+

Step 2: (After pressing Enter having the cursor at the last ‘+’ Result will be like the below one)

Step 3: (press TAB to create more Rows)

In this ' + ' represents the column borders and ' – ' represents the length of the each column. It is one of the Easter Egg in Microsoft Word.

This Simple way can be used at urgent times.

Hope this will be useful.

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-Share Alike 2.5 License.