{
  "$type": "site.standard.document",
  "bskyPostRef": {
    "cid": "bafyreifj7asl5eb5sd7d672azystsw4c4tjq4do3bqmu6notbmalfjswxe",
    "uri": "at://did:plc:25rdn5elo5izoxrmtis34zuk/app.bsky.feed.post/3mpuia5dlrdz2"
  },
  "coverImage": {
    "$type": "blob",
    "ref": {
      "$link": "bafkreia3bhjb3mytpfkw2nk3fxudnsydzcum2r2f6wzlg4punvi3mgzlxi"
    },
    "mimeType": "image/webp",
    "size": 51378
  },
  "path": "/irza_hashim/a-beginners-guide-to-for-loops-in-java-1g12",
  "publishedAt": "2026-07-05T01:09:44.000Z",
  "site": "https://dev.to",
  "tags": [
    "java",
    "beginners",
    "programming",
    "tutorial"
  ],
  "textContent": "Looping is a core concept in computer science. If you need to repeat a task multiple times, you use a loop. In this short tutorial, we will learn exactly how a Java for loop works using a simple code example.\n\n##  The Code Example\n\nHere is a basic Java loop that prints a message five times:\n\n\n\n    for (int i = 0; i < 5; i++) {\n        System.out.println(\"The value of i is: \" + i);\n    }\n\n\n##  How the Code Works Step-by-Step\n\nA for loop has three main parts inside the parentheses, separated by semicolons:\n\n  * **`int i = 0;` (Initialization):** This creates a counter variable named `i` and sets it to 0. It only runs once when the loop starts.\n  * **`i< 5;` (Condition):** The loop checks this condition before every single run. If `i` is less than 5, the loop runs. If `i` becomes 5, the loop stops immediately.\n  * **`i++` (Increment):** This adds 1 to the counter variable `i` at the end of every loop cycle.\n\n\n\n##  The Output\n\nWhen you run this Java program, the computer will print this exact output on your screen:\n\n\n\n    The value of i is: 0\n    The value of i is: 1\n    The value of i is: 2\n    The value of i is: 3\n    The value of i is: 4\n",
  "title": "A Beginner's Guide to For Loops in Java"
}