The program below print numbers on the screen using Java. It is the solution to Deitel’s Java How to Program (9th Edition) Chapter 2 Exercise 2.14.

Question: Write an application that displays the numbers 1 to 4 on the same line, with each pair of adjacent numbers separated by one space. Use the following techniques:

  1. one System.out.println statement.
  2. four System.out.print statements.
  3. one System.out.printf statement.

Java program to print numbers
Sample program

1 Comment

  1. I read a lot of stuff and I found that the writing clarifying that exactly want to say was very good so I am impressed and I will like to come again in future..

Write A Comment