🔥 Day 3: Control Flow, Methods & Arrays in Java! 🔥
Today’s session was packed with key Java fundamentals that are crucial for writing modular and efficient Selenium automation scripts! 🚀
🔹 What I Learned Today:
✅ If-Else Statements – Making decisions 🤔
✅ Loops (For, While, Do-While) – Automating repetitive tasks 🔄
✅ Switch Case – Handling multiple conditions efficiently 🎯
✅ Break & Continue – Controlling loop execution 🚀
✅ Methods (Functions) in Java – Reusability & Modularity ⚡
✅ Method Overloading – Multiple methods with the same name but different parameters
✅ Arrays in Java – One-Dimensional & Two-Dimensional 🔢
📌 Step 1: If-Else Statements (Decision Making)
Java executes code based on conditions using if-else.
📌 Example:
🔹 Use Cases: Login validation, eligibility checks, test assertions in Selenium ✅
📌 Step 2: Loops (For, While, Do-While) – Automating Repetitive Tasks
Loops automate repetitive tasks without writing duplicate code!
🔸 For Loop (Fixed Iterations)
🔸 While Loop (Run Until Condition is False)
🔸 Do-While Loop (Runs At Least Once)
🔹 Use Cases: Web scraping, retry mechanisms in Selenium automation 🔄
📌 Step 3: Switch Case – Handling Multiple Conditions
Instead of multiple if-else statements, we use switch-case for better readability.
📌 Example:
🔹 Use Cases: Dropdown selections, menu-based test automation, handling multiple web elements 🔄
Recommended by LinkedIn
📌 Step 4: Methods (Functions) in Java – Reusability & Modularity
A method (also called a function) is a block of reusable code that performs a specific task.
📌 Example:
🔹 Types of Methods in Java:
✅ Static Methods (can be called without creating an object)
✅ Non-Static Methods (require an object of the class to be used)
📌 Step 5: Method Overloading – Multiple Methods with the Same Name
Method Overloading allows us to define multiple methods with the same name but different parameters.
📌 Example:
🔹 Use Cases: Logging frameworks, data handling, Selenium automation utilities ✅
📌 Step 6: Arrays in Java – One-Dimensional & Two-Dimensional
An array is a collection of elements stored in a single variable.
🔸 One-Dimensional Array
🔸 Two-Dimensional Array
🔹 Use Cases: Storing test data, handling dynamic web elements in Selenium ✅
🔹 Key Takeaways from Day 3
✅ If-Else helps in making decisions
✅ Loops automate repetitive actions
✅ Switch Case is great for handling multiple conditions
✅ Methods (Functions) improve reusability & modularity
✅ Method Overloading allows multiple functions with the same name
✅ Arrays help store multiple values efficiently
📌 Next Up: Java OOPs Concepts – Encapsulation, Inheritance, Polymorphism & Abstraction!
🚀 This journey is getting even more exciting! Drop a 🔥 in the comments if you’re learning Java too!