Javatpoint Logo
Javatpoint Logo

Java PrintWriter println() method

The println() method of java PrintWriter class consist of 10 types with parameters :-

println()

println(boolean b)

println(char c)

println(char[] s)

println(inti)

println(long l)

println(float f)

println(double d)

println(String s)

println(object obj)


Java PrintWriter println() Method

The println() method of Java PrintWriter class terminates the current line. It is done by writing the line separator string.

Syntax

Parameter

NA

Example 1

Test it Now

Output:

terminating the line...

done!

Example 2

Output:

terminating the line in file...
done! check the file.

Java PrintWriter println(boolean b) Method

The println(boolean b) method of java PrintWriter class prints a value which is Boolean and terminates the current line by writing line separator string. This method behaves as it first invokes print(boolean) and then println().

Syntax

Parameter

b - the Boolean value.

Example 1

Test it Now

Output:

Printing boolean and terminating the line...
true
done!

Example 2

Output:

Printing boolean to the file and terminating the line...
done! check the file.

Java PrintWriter println(char c) Method

The println(char c) method of Java PrintWriter class prints a character value and terminates the current line by writing line separator string. This method behaves as it first invokes print(char) and then println().

Syntax

Parameter

c - the character.

Example 1

Test it Now

Output:

Printing char and terminating the line...
s
done!

Example 2

Output:

Printing char to the file and terminating the line...
done! check the file.

Java PrintWriter println(char[] c ) Method

The println(char[] c) method of Java PrintWriter class prints an array of characters and terminates the current line by writing line separator string. This method behaves as it first invokes print(char[]) and then println().

Syntax

Parameter

c - the array of characters.

Example 1

Test it Now

Output:

Printing char array and terminating the line...
shubham jadon
done!

Example 2

Output:

Printing char array to the file and terminating the line...
done! check the file.

Java PrintWriter println(int i) Method

The println(int i) method of Java PrintWriter class prints an integer value and terminates the current line by writing line separator string. This method behaves as it first invokes print(int) and then println().

Syntax

Parameter

i - an integer value.

Example 1

Test it Now

Output:

Printing int and terminating the line...
10
done!

Example 2

Output:

Printing int to the file and terminating the line...
done! check the file.

Java PrintWriter println(long l) Method

The println(long l) method of Java PrintWriter class prints a long value and terminates the current line by writing line separator string. This method behaves as it first invokes print(long) and then println().

Syntax

Parameter

l - the long value.

Example 1

Test it Now

Output:

Printing long and terminating the line...
1003997
done!

Example 2

Output:

Printing long to the file and terminating the line...
done! check the file.

Java PrintWriter println(float f) Method

The println(float f) method of java PrintWriter class prints a float value and terminates the current line by writing line separator string. This method behaves as it first invokes print(float) and then println().

Syntax

Parameter

f - the float value.

Example 1

Test it Now

Output:

Printing float and terminating the line...
1003997.0
done!

Example 2

Output:

Printing float to the file and terminating the line...
done! check the file.

Java PrintWriter println(double d) Method

The println(double d) method of Java PrintWriter class prints a double value and terminates the current line by writing line separator string. This method behaves as it first invokes print(double) and then println().

Syntax

Parameter

d - the double value.

Example 1

Test it Now

Output:

Printing double and terminating the line...
1003997.0
done!

Example 2

Output:

Printing double to the file and terminating the line...
done! check the file.

Java PrintWriter println(String s) Method

The println(String s) method of Java PrintWriter class prints a String value and terminates the current line by writing line separator string. This method behaves as it first invokes print(String) and then println().

Syntax

Parameter

s - the string value.

Example 1

Test it Now

Output:

Printing string and terminating the line...
My name is Shubham Jadon.
done!

Example 2

Output:

Printing string to the file and terminating the line...
done! check the file.

Java PrintWriter println(object obj) Method

The println(object obj) method of Java PrintWriter class prints an object and terminates the current line by writing line separator string. This method behaves as it first invokes print(object) and then println().

Syntax

Parameter

obj - the object.

Example 1

Test it Now

Output:

Printing object and terminating the line...
My name is Shubham Jadon.
done!

Example 2

Output:

Printing object to the file and terminating the line...
done! check the file.

Next TopicJava PrintWriter





Youtube For Videos Join Our Youtube Channel: Join Now

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA