How to get from java.lang.Object to a different type
From: FruitfulToon (sorepharynx_at_hotmail.com)
Date: 02/28/04
- Next message: Larry Barowski: "Re: Change look and feel on the fly?"
- Previous message: david: "Re: Newbie Question: Which IDE Should I Start With"
- Next in thread: Rob: "Re: How to get from java.lang.Object to a different type"
- Reply: Rob: "Re: How to get from java.lang.Object to a different type"
- Reply: Jon A. Cruz: "Re: How to get from java.lang.Object to a different type"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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
- Next message: Larry Barowski: "Re: Change look and feel on the fly?"
- Previous message: david: "Re: Newbie Question: Which IDE Should I Start With"
- Next in thread: Rob: "Re: How to get from java.lang.Object to a different type"
- Reply: Rob: "Re: How to get from java.lang.Object to a different type"
- Reply: Jon A. Cruz: "Re: How to get from java.lang.Object to a different type"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]