Java’s Print similarities to C

As we know that java is made by the C programming. The java has many common features to C language. While we wants to print in java we usually use the following code.

But there is also the feature of printf in java which we used to do in C programming:

Syntax:

For eg:

which outputs like this in C :
c-out

But in JavaRead More »Java’s Print similarities to C

ToString() method

The toString() method is one of the feature of java. It is the method of class String which is imported default on JVM from java.lang.Object;

ToString() method is one of the display method.

When ever we tries to print the text from System.out.println("Hello"); then it directly inherit from the toString() method. We can override the toString() method and make the println to print what we desire.
Read More »ToString() method

Exception Handler

Here we are going to start a exception handler of handling the occurance of error.

To start the exception we must know a few info about the try{} catch() and finally{}.

Try{}
This try helps is to try any operation and if there appears any error then it directly goes to the catch() method to check either the error matches with the exception defined at catch(). If no any catch is found then it directly goes to finally{} method for end of try{} method.

Read More »Exception Handler

Accepting Keyboard Input

First of all we need to know that in java for printing the line we use following command:

System.out.println();
While we code the System then it is related with input and output and all the hardware conf.
Then the keyword out defines about the display of the line.
Now we need to input instead of output.
So just code by following ways:
System.in.read();
Read More »Accepting Keyboard Input