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");
}
}
//print in Java
System.out.println("Welcome to Java");
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");
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");
}
}
System.out.println("simple message");
/* 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
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();
}
}