what is java for code example

Example 1: java for loop

for(int i = 0; i < 10; i++)
{
  //do something
  
  //NOTE: the integer name does not need to be i, and the loop
  //doesn't need to start at 0. In addition, the 10 can be replaced
  //with any value. In this case, the loop will run 10 times.
  //Finally, the incrementation of i can be any value, in this case,
  //i increments by one. To increment by 2, for example, you would
  //use "i += 2", or "i = i+2"
}

Example 2: for loop in java

// for loop in java
public class ForLoop
{
   public static void main(String[] args)
   {
      for(int x = 1; x <= 5; x++)
      {
         System.out.println(x);
      }
   }
}

Example 3: what is java

Java is a general-purpose programming language that is 
class-based, object-oriented, and designed to have as 
few implementation dependencies as possible.

Hello World in Java:
public class FileName {
  public static void main(String args[]) {
    System.out.println("Hello World!");
  }
}

Example 4: java for loop

// Example of a for loop in java that will iterate the number of times entered by the user
import java.util.Scanner; // import Scanner class
public class grepperjava {
    public static void main(String[] ARGS)
    {
        System.out.println("\nPlease enter a number, and the loop will iterate input times.");
        int input;
        Scanner var = new Scanner(System.in); // Create scanner object, so user-input may be read
        input = var.nextInt();
        var.close();

        for(int i = 0; i < input; i++)
        {
            System.out.println("This will print " + input + " times");
        }
    }
}

Example 5: what is java

Java is dynamic. It’s an object oriented programming language.
architecture-neutral. Because applications written in java are convenient 
across many platforms.

Tags:

Misc Example