Question: ```
ArrayList<yellowPage> ob1 = new ArrayList<yellowPage>(); 
yellowPage thing = new yellowPage(100,100);
thing.calc(i,y,s3); 
ob1.add(thing);

```

I stored some data in `thing`. How can I retrieve the value stored in `ob1.thing`?

Answer: 
Print the list and override toString method.

```
public String toString()
{
 return (""+ a+b);    //Here a and b are int fields declared in class
}

System.out.print(ob1);

```
```
Class ArrayList<E>

```

Syntax

```
ArrayList<Integer> list = new ArrayList<Integer>();

```

You replace "Integer" with the class that the list is of.
An application can increase the capacity of an ArrayList instance before adding a large number of elements using the ensureCapacity operation. This may reduce the amount of incremental reallocation.
E represents an Element, which could be any class.
`ensureCapacity` is used to ensure that the list has enough capacity to take in the new elements. It's called internally every time you add a new item to the list. As the name suggests, `ArrayList` uses an Array to store the items. So when the array is initialized, it's given an arbitrary length, say 10. Now once you've added 10 items, if you go to add the 11th item, it'll crash because it exceeds the arrays capacity. Hence, `ensureCapacity` is called (internally) to ensure that there's enough space. So if you were adding the 11th element, the array size might be, say, doubled, to 20.