Sunday, 25 June 2017

Writing a program to print output in java ~ foundjava

There are several ways to print an output in java. We can use any of the following methods to print the output.
public class printOutput
{
    public static void main(String args[])
    {
    System.out.println("Hi");
    System.out.print("Hello world!");
    System.out.print("I am in print method");
    }
}
System : It is a class in java.lang, the default package.
out : It is a reference of java.io.PrintStream object and it is also a static member of System class.
println : Prints in a new line.
print : Prints the output.
printf : It works as printf in C/C++.

No comments:

Post a Comment