A simple Lucky draw Program
Here I’m going to show a simple program which picks random 6 character and assigns the point for that code no. If it consists vowel… Read More »A simple Lucky draw Program
Here I’m going to show a simple program which picks random 6 character and assigns the point for that code no. If it consists vowel… Read More »A simple Lucky draw Program
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.
1 2 3 |
System.out.println(<em>statement1</em>); or System.out.print(<em>statement2</em>); |
But there is also the feature of printf in java which we used to do in C programming:
Syntax:
1 2 3 4 5 |
//In C language <strong>printf</strong>("format_string", comma_separated_list_of_expressions); //In JAVA System.out.<strong>printf</strong>("format_string", separated_list_of_expressions); |
For eg:
1 2 3 4 5 6 |
//In C we use void main(){ int sum = 4; printf("The sum is %d , sum); } |
which outputs like this in C :
But in JavaRead More »Java’s Print similarities to C
Probably we used to declare the method and class as a public .
But the there is also the classes where there is no any public
or any private .
We can make two or many classes in a single class file.
* But when declaring numerous class the class file must contain
at least one public class whose class must match to class file
name.
Read More »A Public Vs. Nonpublic Classes
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
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.