xxxxxxxxxx
public class Main
{
public static void main(String[] args) {
System.out.println("Java Print");
}
}
xxxxxxxxxx
class Output {
public static void main(String[] args) {
System.out.println("1. println ");
System.out.println("2. println ");
System.out.print("1. print ");
System.out.print("2. print");
}
}
xxxxxxxxxx
public class MyClass {
public static void main(String[] args) {
System.out.println("Hello, world!");
}
}
xxxxxxxxxx
public class Something {
public static void main(String args[]) {
Scanner s = new Scanner(System.in);
char c1,c2;
c1 = s.findWithinHorizon(".", 0).charAt(0);
c2=s.findWithinHorizon(".", 0).charAt(0);
System.out.print(c1);
System.out.print(c2);
s.close();
}
}
xxxxxxxxxx
/* The println() function adds a new line after printing
the value/data inside it. Here, the suffix ln works as the
newline character, \n. 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 ( \n ).
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