[Java] ArrayList

As I was writting the Voucher Reporting Tool for GE Aviation, the process of storing data in arrays became more and more tedious. Every time I wanted to add another engine, or remove a DAN #, I have to write all those codes to create a new array, filling it in, arranging it and such. Why can’t arrays be resized? Anyway, I turned to the ArrayList class, which I should have been a long time ago.

I guess it is similar to the Data Structure called Linked List, but all coded out by other devs and ready for use. Here’s a simple example.

import java.util.ArrayList;

public class Testing {

public static void main(String[] args) {

//Defining the Array List
ArrayList list = new ArrayList();

//Adding Elements in Order

//Add Element at a certain Index
list.add(2, "Two and a Half");

//Revoce Element by Index Number

//Remove Element by supplying the Object

//Retrieve Elements in the Array List
for(int i = 0; i < list.size(); i ++)

//Search for a certain Element Index
System.out.println("Two is at position: "+list.indexOf("Two"));



Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s