1. Basic Java Syntax + Structure

  • The AP test focuses on logic > syntax (Should note that the reader needs to find these obvious mistakes)
    • Variables don’t have to be completely case sensitive (you can have spelling mistakes)
    • Can use common math operators
    • missing semi-colons, parentheses, etc.
    • missing indentation
  • Structure
    • Calling methods
    • Writing methods
    • Handling return values
    • Method Parameters

      2. Arrays

  • Use: storing + acessing values
  • Syntax: int[] arr = new int[10]; for an integer array with 10 elements.
  • Accessing Elements: arr[0] accesses the first element.
  • Looping through Arrays: Use a for loop to iterate over arrays, e.g., for (int i = 0; i < arr.length; i++) {}.

    3. ArrayLists

  • Use: Dynamic Arrays (can grow and shrink dynamically)
  • Syntax: ArrayList list = new ArrayList(); where Type could be any object type (e.g., Integer, String).
  • Adding Elements: list.add(element);
  • Size: list.size();
  • Removing Elements: list.remove(index);

    4. String Handling:

  • Comparing Strings:: Use .equals() for content comparison (not == which checks reference equality)
  • Concatenation: Use + for simple concatenation or StringBuilder for more efficient concatenation in loops.

    5. Control Flow Structures:

  • Conditionals: if, else if, else

    6. Libraries + Reference

  • image
  • Assume all classes are preimported and all methods are available. The question should be able to be solved with these methods. (Remember these are not complex!)