Javatpoint Logo
Javatpoint Logo

Java PrintStream print() method

The print() method of java PrintStream class consist of 9 types with parameters :-

  1. print(boolean b)
  2. print(char c)
  3. print(char[] s)
  4. print(int i)
  5. print(long l)
  6. print(float f)
  7. print(double d)
  8. print(String s)
  9. print(object obj)

Java PrintStream print(boolean b) Method

The print(boolean b) method of java PrintStream class prints a value whose type is boolean.

Syntax

Parameter

b - the Boolean value.

Returns

NA

Example 1

Test it Now

Output:

Printing boolean value....
true

Example 2

Output:

printing boolean value...
Done !, check the text file.

Java PrintStream print(char c) Method

The print(char c) method of java PrintStream class prints a character value.

Syntax

Parameter

c - the character to be printed.

Returns

NA

Example 1

Test it Now

Output:

Printing char value....
A

Example 2

Output:

printing char value...
Done !, check the text file.

Java PrintStream print(char[] c ) Method

The print(char[] c) method of java PrintStream class prints an array of characters.

Syntax

Parameter

c - the array of chars to be printed.

Returns

NA

Example 1

Test it Now

Output:

Printing char array value...
shubham jadon

Example 2

Output:

printing char array value...
Done !, check the text file.

Java PrintStream print(int i) Method

The print(int i) method of java PrintStream class prints an integer value.

Syntax

Parameter

i - an integer value.

Returns

NA

Example 1

Output:

printing int value...
Done !, check the text file.

Example 2

Test it Now

Output:

Printing int value...
1031997

Java PrintStream print(long l ) Method

The print(long l) method of java PrintStream class prints a long value.

Syntax

Parameter

l - the long value to be printed.

Returns

NA

Example 1

Output:

printing long value...
Done !, check the text file.

Example 2

Test it Now

Output:

Printing long value...
1031997

Java PrintStream print(float f) Method

The print(float f) method of java PrintStream class prints a floating-point number.

Syntax

Parameter

f - the float value.

Returns

NA

Example 1

Test it Now

Output:

Printing float value...
10.0

Example 2

Output:

printing float value...
Done !, check the text file.

Java PrintStream print(double d) Method

The print(double d) method of Java PrintStream class prints a double value.

Syntax

Parameter

d - the double value.

Returns

NA

Example 1

Test it Now

Output:

Printing double value...
10.0

Example 2

Output:

printing double value...
Done !, check the text file.

Java PrintStream print(String s) Method

The print(String s) method of Java PrintStream class prints a String value. If the specified argument is null then the string "null" is printed.

Syntax

Parameter

s - the string value.

Returns

NA

Example 1

Test it Now

Output:

Printing String value...
my name is shubham jadon

Example 2

Output:

printing String value...
Done !, check the text file.

Java PrintStream print(object obj) Method

The print(object obj) method of Java PrintStream class prints an object.

Syntax

Parameter

obj - the object to be printed.

Returns

NA

Example 1

Test it Now

Output:

Printing object value...
my name is shubham jadon

Example 2

Output:

printing object value...
Done !, check the text file.

Next TopicJava PrintStream





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