> For the complete documentation index, see [llms.txt](https://www.precollege.net/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://www.precollege.net/session-9/source-code.md).

# Source Code

## Session9.java

```java
import java.util.*;

public class Session9 {
    public static void main(String[] args) {
        String myName = ""; // add your name
        System.out.println("Session 9" + " - " + myName);

        // Menu
        System.out.println("Menu");
        System.out.println("E1 - Example 1");
        System.out.println("Q  - Quit");

        // setup Scanner
        Scanner in = new Scanner(System.in);
        System.out.print("Choice: ");
        String choice = in.nextLine();

        // switch choices
        switch (choice) {
            case "E1":
                System.out.println("Example 1");
                example1();
                break;
            case "E2":
                System.out.println("Example 2");
                example2();
                break;
            case "E3":
                System.out.println("Example 3");
                example3();
                break;
            case "E4":
                System.out.println("Example 4");
                example4();
                break;
            case "E5":
                System.out.println("Example 5");
                example5();
                break;
            case "E6":
                System.out.println("Example 6");
                example6();
                break;
            case "E7":
                System.out.println("Example 7");
                example7();
                break;
            case "Q":
                System.out.println("Quitting..!");
                break;
        }
    }

    // example1 method
    public static void example1() {
        // declare and initalize an ArrayList of students
        

        // add elements
        

        // print elements
        

        // insert "Abi" at index 0
        

        // set "Devin" at index 3
        

        // print elements
        

    }

    // example2 method
    public static void example2() {
        // declare and initalize an ArrayList of numbers
        

        // add elements
        

        // get elements
        

    }
    // example3 method
    public static void example3() {
        // Create an ArrayList of top colleges
        ArrayList<String> colleges = new ArrayList<>();

        // Add top 10 colleges to the list
        colleges.add("Massachusetts Institute of Technology (MIT)");
        colleges.add("Stanford University");
        colleges.add("Harvard University");
        colleges.add("California Institute of Technology (Caltech)");
        colleges.add("University of Chicago");
        colleges.add("Princeton University");
        colleges.add("Yale University");
        colleges.add("Columbia University");
        colleges.add("University of Pennsylvania");
        colleges.add("Duke University");

        // for loop to traverse the ArrayList
        
        
    }

    // example4 method
    public static void example4() {
        // Create an ArrayList of words
        ArrayList<String> words = new ArrayList<>(Arrays.asList("Java", "is", "awesome"));

        // replace the element at index 1 (second element)
        

        
    }

    // example4 method
    public static void example5() {
        // Create an ArrayList of top global universities
        ArrayList<String> universities = new ArrayList<>();

        // Add top 10 universities globally
        universities.add("Massachusetts Institute of Technology (MIT) - USA");
        universities.add("Stanford University - USA");
        universities.add("Harvard University - USA");
        universities.add("University of Cambridge - UK");
        universities.add("University of Oxford - UK");
        universities.add("California Institute of Technology (Caltech) - USA");
        universities.add("Imperial College London - UK");
        universities.add("ETH Zurich - Switzerland");
        universities.add("University College London (UCL) - UK");
        universities.add("University of Chicago - USA");

        // Remove by index
        

        // Remove by value
        

        // Print the list of top global universities
        

    }

    // example6 method
    public static void example6() {
        // Create an ArrayList of numbers
        ArrayList<Integer> numArray = new ArrayList<>();
        numArray.add(10);
        numArray.add(-5);
        numArray.add(20);
        numArray.add(-15);
        numArray.add(30);

        // while loop
        

        // while loop and deleting
        

        // enhanced for loop
        

    }
    // example7 method
    public static void example7() {
        
        
    }
}
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://www.precollege.net/session-9/source-code.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
