Life without Generics : Generics Basics « Generics « Java Tutorial

When retrieving a member from stringList1, you get an instance of java.lang.Object. In order to work with the original type of the member element, you must first downcast it to String.

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

public class MainClass {

  public static void main(String[] args) {
    List stringList1 = new ArrayList ();
    stringList1.add ("Java 5");
    stringList1.add ("with generics");

    String s1 = (String) stringList1.get (0);


12.1.Generics Basics
12.1.1.Life without Generics
12.1.2.What Are Generics? A Simple Generics Example
12.1.3.Generics Work Only with Objects
12.1.4.A Generic Class with Two Type Parameters
12.1.5.Introducing Generic Types
12.1.6.Working with generic List
12.1.7.Nested generic type
12.1.8.A generic type can accept more than one type variables.
12.1.9.Raw Types and Legacy Code