Array List Explanation

An array list is an array that you can manipulate the size of. With normal arrays, they have their size set from the start and you cannot change the preassigned size of that array. However, array list elements can be added and removed from an array list whenever there is a need, helping the user with memory management.

Use of Array Lists

I have decided to use arrays to display some information about different types of cars. Array lists allow me to display information simply and in a way that is relatively easy to read.

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

public class Vehicle{
    private String model;
    private String make;
    private String cost;
    private String acceleration;
    private int seats;
    private String engine;

    public Vehicle(String model, String make, String cost, String acceleration, int seats, String engine){
        this.model = model;
        this.make = make;
        this.cost = cost;
        this.acceleration = acceleration;
        this.seats = seats;
        this.engine = engine;
    }

    public String toString() {
        return String.format("%s\t\t%s\t\t%s\t%s\t%d\t%s", model, make, cost, acceleration, seats, engine);
    }

    public static void main(String[] args){
        List<Vehicle> listVehicles = new ArrayList<Vehicle>();

        listVehicles.add(new Vehicle("TLX", "Acura", "54,500 USD", "5.9 seconds", 5, "355.0-hp, 3.0-liter, V6 Cylinder"));
        listVehicles.add(new Vehicle("Camry", "Toyota", "36,270 USD", "5.1 seconds", 5, "301.0-hp, 3.5-liter, V6 Cylinder"));
        listVehicles.add(new Vehicle("Camaro", "Chevy", "43,500 USD", "5.2 seconds", 4, "455.0-hp, 6.2-liter, 8 Cylinder"));
        listVehicles.add(new Vehicle("Model S", "Tesla", "135,990 USD", "1.99 seconds", 5, "no lol"));
        listVehicles.add(new Vehicle("SF90", "Ferrari", "511,295 USD", "2.33 seconds", 2, "986.0-hp, 4.0-liter, 8 Cylinder "));
        listVehicles.add(new Vehicle("Beetle", "Volkswagen", "20,895 USD", "7.9 seconds", 4, ))
        

        for (Vehicle n : listVehicles){
            System.out.println(n);
        }
    }
}

Vehicle.main(null);
TLX		Acura		54,500 USD	5.9 seconds	5	355.0-hp, 3.0-liter, V6 Cylinder
Camry		Toyota		36,270 USD	5.1 seconds	5	301.0-hp, 3.5-liter, V6 Cylinder
Camaro		Chevy		43,500 USD	5.2 seconds	4	455.0-hp, 6.2-liter, 8 Cylinder
Model S		Tesla		135,990 USD	1.99 seconds	5	no lol
SF90		Ferrari		511,295 USD	2.33 seconds	2	986.0-hp, 4.0-liter, 8 Cylinder 

Science Olympiad Website

We are creating a Science Olympiad Website. To make it a fully functioning website, integration of array lists would be crucial for carrying out the functions that we would like to include.

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

public class Member{
    private String firstname;
    private String lastname;
    private String role;
    private int grade;
    private String email;

    public Member(String firstname, String lastname, String role, int grade, String email){
        this.firstname = firstname;
        this.lastname = lastname;
        this.role = role;
        this.grade = grade;
        this.email = email;
    }

    public String toString() {
        return String.format("%s\t%s\t%s\t%d\t%s", firstname, lastname, role, grade, email);
    }

    public static void main(String[] args){
        List<Member> listMembers = new ArrayList<Member>();

        listMembers.add(new Member("Krish", "Patil", "Leadership", 11, "krishpatil1019@gmail.com"));
        listMembers.add(new Member("Don", "Tran ", "Leadership", 11, "donqt@gmail.com"));
        listMembers.add(new Member("Rohan", "Gaikwad", "Vice President", 11, "gaikwadrohan326@gmail.com"));
        listMembers.add(new Member("Audrey", "Zeng", "President", 12, "audreyhuaxia@gmail.com "));
        listMembers.add(new Member("Nick", "Ramos", "no      ", 11, "nicky.jay77@gmail.com"));
        listMembers.add(new Member("Nathan", "Mananga", "coder   ", 10, "nathanmanangan@gmail.com"));
        

        for (Member n : listMembers){
            System.out.println(n);
        }
    }
}

Member.main(null);
Krish	Patil	Leadership	11	krishpatil1019@gmail.com
Don	Tran 	Leadership	11	donqt@gmail.com
Rohan	Gaikwad	Vice President	11	gaikwadrohan326@gmail.com
Audrey	Zeng	President	12	audreyhuaxia@gmail.com 
Nick	Ramos	no      	11	nicky.jay77@gmail.com
Nathan	Mananga	coder   	10	nathanmanangan@gmail.com

The above table shows some of the members, their roles, grades, and emails