🚀 Day 28 of My Automation Journey – Nested For Loop
Today’s learning was super important 👇 👉 Moving from single loops → nested loops 👉 This is where pattern logic begins 🔥 🔹 1. What is a Nested Loop? 👉 A loop inside another loop is called a ne...

Source: DEV Community
Today’s learning was super important 👇 👉 Moving from single loops → nested loops 👉 This is where pattern logic begins 🔥 🔹 1. What is a Nested Loop? 👉 A loop inside another loop is called a nested loop 💡 Structure: for(row) { for(column) { // logic } } 🧠 How It Works 👉 Outer loop → controls rows 👉 Inner loop → controls columns 🔹 2. Basic Example (Print 1’s) for(int row = 1; row <= 2; row++) { for(int col = 1; col <= 5; col++) { System.out.print(1); } System.out.println(); } 📤 Output: 11111 11111 🔹 3. Print Row Number for(int row = 1; row <= 2; row++) { for(int col = 1; col <= 5; col++) { System.out.print(row); } System.out.println(); } 📤 Output: 11111 22222 🔹 4. Print Column Number for(int row = 1; row <= 2; row++) { for(int col = 1; col <= 5; col++) { System.out.print(col); } System.out.println(); } 📤 Output: 12345 12345 🔹 5. Rectangle Pattern ⭐ for(int row = 1; row <= 3; row++) { for(int col = 1; col <= 5; col++) { System.out.print("*"); } Syst