How to get from java.lang.Object to a different type

From: FruitfulToon (sorepharynx_at_hotmail.com)
Date: 02/28/04


Date: 28 Feb 2004 09:20:22 -0800

Hi, I have made a linked list that is full of objects of type T, and
when I try to get the objects out of the linked list the error is that
the types are incompatable. ie. T is not the same as java.lang.object.

Surely there is a way to convert java.lang.object back to T???

Here is the code i have.

import java.util.*;

class T
{
        int n;
        public T(int n)
        {
                this.n=n;
        }
        
        public int get()
        {
                return n;
        }
                
}

class test
{

        public static void main(String[] args)
        {
                LinkedList store = new LinkedList();
                
                T tester = new T(3);
                store.add(tester);
                
                T temp = store.getFirst();

        }
}

thanks a lot

Alex