Printing Program Output in Java

(Last Updated On: February 23, 2019)

Learn how to print program output in java on console screen using system.out.println method. You will learn how to print Strings, int and double variables etc on console.

Here is a simple java program that prints output as “I love Java Programming”.


I Love Java Programming

Notice that string “I Love Java programming” is in double quote.



Printing Multiple Strings on Console

Here is another example of printing multiple strings in java program.

My name is Peter
I am learning Java
I like Coffee


Printing variables on Console

You can print value of int, double and String variables in java program on console screen.

Java code:

I Like Coffee


Printing multiple values in one line on Console

You can print multiple types of data by appending them using + symbol in system.out.println method in one line.

Java code example:

In below program an int variable and a string variable are appended in system.out.println method using + symbol.

100 Coffee!!!



Beginners make mistake of using common symbol (,) instead of (+ )symbol . For example, System.out.println(count,str);


One more example below on console output in java,

that is appending a hard code string “value = “ and an int value of variable num.


value= 100

NOTE: Having space before or after + symbol, does not affect the output. For example, in above program, both statements given below produces same output.




Exercises on Printing Output on Console in Java


Exercise 1: Print below 3 strings using a single system.out.printl method. No need to create String variables for them.

“I am going to be expert in”
“java programming”
“in few days”


Exercise 2: Use below program. Print the output as given below in one line. You don’t have to write any extra system.out.println method.


I will practice 10 programs today

NOTE: Did you find output as “I will practice10Today”? Use space between all values using string “ “.





Notice: spaces has been used as a string value i.e. ” ” to keep values string , num and str separate.