DEV Community

Cover image for Difference between print() and println() in Java
Lalit Kumar
Lalit Kumar

Posted on

Difference between print() and println() in Java

Print():

print() function in Java is used to show a text on the console. This text is approved as the parameter to this function in the form of String. This function prints the typescript on the console and the pointer leftovers at the end of the typescript at the console.

Dissimilarity between print() and println() in Java

The following printing taking place from just here.

Varioud println() methods:

Various print() functions:
void print(boolean b) – Prints a boolean value.
void print(char c) – Prints a char..
void print(char[] s) – Prints an array of char.
Enter fullscreen mode Exit fullscreen mode

Example

import java.io.*; 
class KodLogs { 
    public static void main(String[] args) 
    { 
        // The pointer will remain 
        // just afterward the 1 
        System.out.print("Gf1G12"); 
        // This will be printed 
        // just after the Gf1G12 
        System.out.print("Gf1G12"); 
    } 
} 


Output:
Gf1G1GfG2
Enter fullscreen mode Exit fullscreen mode

Read more

Top comments (0)