Look at the source code of the existing collection classes in Java to see how you can implement your own generic collection type. Also, read my reply here .
~s.o.s~
Failure as a human
11,938 posts since Jun 2006
Reputation Points: 3,281
Solved Threads: 734
Post a "compilable" and "short" piece of code which demonstrates your problem.
~s.o.s~
Failure as a human
11,938 posts since Jun 2006
Reputation Points: 3,281
Solved Threads: 734
This is because the getObject() methods returns an Object and the Object class doesn't have the methods `getName` and `getAge`. You either need to cast the object returned by the `getObject` method to `Data` or "generify" your List class so that it accepts a type parameter just like the ArrayList class of JDK.
~s.o.s~
Failure as a human
11,938 posts since Jun 2006
Reputation Points: 3,281
Solved Threads: 734
Umm. You are programming in Java and don't understand how to do a cast? Try looking for cast or typecast in the index of your text. This will be the fastest fix because it is the easiest to understand. "Generifying" your collection would be the better long term fix, if: You know you are going to always be holding instances of Data and you want to avoid writing casts "everywhere".
griswolf
Veteran Poster
1,165 posts since Apr 2010
Reputation Points: 344
Solved Threads: 256