For Loop in Java
Java is a popular object-oriented programming language developed by James Gosling at Sun Microsystems. It is known for its “write once, run anywhere” approach, as Java programs can be executed on any platform with the Java Virtual Machine (JVM).
public class Main {
public static void main(String[] args) {
for (int i = 0; i < 5; i++) {
System.out.println(i);
}
}
}
Output
0 1 2 3 4
For loop in Programming
For loop is one of the most widely used loops in Programming and is used to execute a set of statements repetitively. We can use for loop to iterate over a sequence of elements, perform a set of tasks a fixed number of times. In this article, we will learn about the basics of For loop, its syntax along with its usage in different programming languages.
Table of Content
- What is For Loop?
- For Loop Syntax
- How does For Loop work?
- For Loop in different programming languages
- For Loop in C
- For Loop in C++
- For Loop in Java
- For Loop in C#
- For Loop in Python
- For Loop in JavaScript
- For Loop in PHP
- For Loop Use Cases
- Types of For Loops
- For Loop vs other loops
Contact Us