How to print statement using java?

Printing statements in java

In java, System.out.println() is used to print the argument. The printing statement is classified into three methods.

1. print(): To use print text on the console and the next text is printed at the remaining end of the old print. It takes a string as a parameter.
System.out.print();

2.println(): To use print text on the console and the next text is printed at the new line. It takes a string as a parameter.
System.out.println();

3. printf(): To use print format strings using various format specifiers and also an overloaded method of the PrintStream class.
System.out.printf(string);
System.out.printf(format,arguments);
System.out.printf(locale,format,arguments);

PROGRAM
public class printf {
            //main method
            public static void main(String[] args) {
                //print();
                System.out.print("Name:john ");
                //println();
                System.out.println("Place:America");
                //printf();
                System.out.printf("Age:%d",34);
                }
            }

Output


print



Post a Comment

0 Comments