Master Doc Notes

Core Java concepts from your master document, including execution flow, loops, collections, and practical examples for automation.

Java execution flow

Java source files are compiled by javac into bytecode (.class files). The JVM executes bytecode and converts it to machine instructions.

This flow is the foundation for automation code written in Java, including Selenium and API tests.

Palindrome example

public class E_StringPalindromeCheck {
  public static void main(String[] args) {
    String s = "arora";
    String rev = "";
    for (int i = s.length() - 1; i >= 0; i--) {
      rev = rev + s.charAt(i);
    }
    if (s.equals(rev)) {
      System.out.println("palindrome string");
    } else {
      System.out.println("not palindrome");
    }
  }
}

This example shows string reversal, loop control, and conditional checking in Java.

ArrayList iteration

ArrayList al = new ArrayList();
al.add("wasim");
al.add("Amna");
al.add("Daniyal");
al.add("Noida");
al.add("Delhi");

for (int i = 0; i < al.size(); i++) {
  System.out.println(al.get(i));
}

for (String name : al) {
  System.out.println(name);
}

Use indexed loops or enhanced for-each loops depending on whether you need the current index.

While loops

Use a while loop when you want to repeat work until a condition is no longer true.

int i = 1;
while (i <= 5) {
  System.out.println(i);
  i++;
}

Local Master Doc notes

This page is based on your local master training notes and Java examples.

Open local Master Doc notes