Tutorial

Displaying text using printf() method

In addition to the print() and println() methods, the printf () method is also quite frequently used for displaying text th ... 89 Flags call also be provided in the format String to add further formatting. In addition, we can format dates and times.

Formulating Algorithms

Now that we have learnt about two of the control structures, we shall see how we can formulate algorithms using theses struc ... tialised num to 1. But for an operation whose identity value isn’t known, version 2 is the only approach that can be taken.

Naming Conventions for Identifiers

If you have observed every program written by us closely, you would have noticed certain similarities in the way we have ... a variable, a class, an interface or some other entity. Next : Mathematical operations in Java Prev : Java Comments

Taking Input as Command Line Arguments

You must have now by realised what String[] args within the declaration of the main method means. It represents a String a ... from the command line: Next : Using ellipsis to accept variable number of argumentsPrev : Multi dimensional arrays

Default Constructor provided by Compiler

When we do not explicitly provide a constructor to our class, the compiler provides a default constructor which initialise ... ation error would be generated saying that x was not initialized } Next : Access Specfiers Prev : Get and Set Methods

Taking Input from the User

In the addition program that we have written, we have initialised the variables firstNumber and secondNumber with 3 and 4. ... ations in the next chapter. Next : Introduction to object oriented programming Prev : Mathematical operations in Java

this Keyword

The this keyword in Java returns a reference to the object on which the method being executed is invoked. We can use the r ... o argument constructor called”); // incorrect   this(-1); } Next : Wrapper classesPrev : Static methods and variables

Branching Statements

We will now look at the last set of control statements in Java- branching statements. They are used to transfer control to ... now move to arrays in which the for loop is widely employed. Next : Arrays introduction Prev : Formulating algorithms

Nested try catch blocks

Exception handlers can be nested within one another. A try, catch or a finally block can in turn contains another set of try ... lly { System.out.println(“Finally in meth”); } } } The output is Finally in meth ArithmeticException caught Outer finally