public static void main(String[] args){
System.out.println("Hello World");
}
public class Main{
public static void main(String[] args) {
System.out.println("Hello World of Java!!");
}
}
public class Main
{
public static void main(String[] args) {
System.out.println("Java Print");
}
}
System.out.print(<string>); //prints in the same line as the previous print
System.out.println(<string>); //prints in a new line
// Example
System.out.print("This ");
System.out.print("will ");
System.out.print("be ");
System.out.print("all ");
System.out.print("in ");
System.out.print("one ");
System.out.print("line.");
System.out.println("Hello World!");
System.out.println("second line");
public static void main(String[] args){
System.out.println("Hello World"); // system should start with a capital S
} // don't forget a semi colon
public static void main(String[] args){
System.out.println("FUK!");
}
/* The println() function adds a new line after printing
the value/data inside it. Here, the suffix ln works as the
newline character,
. If you consider the following example:
*/
public class Main{
public static void main(String[] args) {
System.out.println("Hello World!");
}
}
/* You might not figure out exactly what is happening under
the hood as you are printing only one line,
and you get the following output:
*/
// Hello World!
/* But if you try to print several different expressions
using the println() then you'll see the difference clearly!
*/
public class Main{
public static void main(String[] args) {
System.out.println("Hello World!");
System.out.println("Welcome to freeCodeCamp");
}
}
/* Here, you can see that after executing the first print
statement, it is adding one new line character (
).
So you are getting the second print statement,
Welcome to freeCodeCamp, in the next line.
The whole output will be like below:
*/
// Hello World!
// Welcome to freeCodeCamp