Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

JAVA Display numbers from 1 to 5

// Program to print numbers from 1 to 5

class Main {
  public static void main(String[] args) {
  
    int n = 5;
    // for loop  
    for (int i = 1; i <= n; ++i) {
      System.out.println(i);
    }
  }
}
Comment

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++;
    }
  }
}
Comment

PREVIOUS NEXT
Code Example
Java :: enhanced 4 loop 
Java :: Java Creating ConcurrentHashMap from Other Maps 
Java :: Rotate array to left k cells python 
Java :: webmvctest vs springboottest 
Java :: java list sort comparator date descending lambda 
Java :: how to fetch email and get there body content in spring boot 
Java :: convertBirthDay java 
Java :: code converter from java to python 
Java :: Java headSet(element, booleanValue) 
Java :: how to get value from property file in spring xml file 
Java :: java memory cleaner 
Java :: Java program to find largest of three numbers using nested if 
Java :: How to Implement GET and POST Requests With Java 
Java :: andriod button wont change color 
Java :: sendPlanUpgrade 
Java :: Draw an item using System.out.println 
Java :: string stack in java 
Java :: java optional input for funktions 
Java :: Rotate Left k cells java 
Java :: trémaux’ method java 
Java :: springBoot Disable a Specific Auto-Configuration 
Java :: java object array initialization 
Java :: how to take input an array in java 
Java :: how to generate a random number in libgdx 
Java :: Java Enable assertion in class names 
Java :: exemple javafx 
Java :: binary search tree 
Java :: arraylist add method 
Java :: instanceof operator java 
Java :: how to make 2d array of strings in java 
ADD CONTENT
Topic
Content
Source link
Name
2+4 =