Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

Java Display Numbers from 1 to 5

// Program to display numbers from 1 to 5

class Main {
  public static void main(String[] args) {

    // declare variables
    int i = 1, n = 5;

    // while loop from 1 to 5
    while(i <= n) {
      System.out.println(i);
      i++;
    }
  }
}
 
PREVIOUS NEXT
Tagged: #Java #Display #Numbers
ADD COMMENT
Topic
Name
1+6 =