Menu Bar

Horizontal Scrollable Menu

Search This Blog

Java Print function with example | Difference between print () and println () in java

Java print

Both the print () and println () methods print data on the screen. Basically print () and println () are almost identical with very little difference between them. These methods are very popular in Java.
 

Difference between print () and println () in java


In Java, the print () and println () methods differ in the way that when using println () in the output screen, the cursor will be shown in the next line after printing the required output on the screen. Basically we can understand 'LN' as 'next line' in 'println'. But in print (), the cursor in the output screen will be shown on the same line after printing the required output on the screen. This is the basic difference between print () and println () methods.

Print () method

The print () method prints the required output on the same line repeatedly on the screen.

Example: Print Helloworld!!

import java.io.*;
import java.util.*;
class Ab 
{
public static void main(String...aa)
{
System.out.println("Hello World");
}
}

No comments:

ads3