my friend told me that with the new update of java 5.0 update7 you can make ArrayLists for a specific object, which i though would save me god knows how much trouble with casting objects back to their true state, but when it came to adding things to these arraylists, this is were my problem starts.
when i try to add something(of the same type the arraylist stores) using the .add(*) method, i get a compilation error telling me "<identifier> expected". what is my problem? i suppose its because i dont know anything about the update except that you can make an ArrayList of a specific type...
[ September 23, 2006: Message edited by: Micah Pezdirtz ]
Originally posted by Micah Pezdirtz:
its going to be a library of these "jutsus" and now i just realized something, i can initialize all these values in main or in a method....is that what i want to do? i want to be able to call something like "JutsuLibrary.jutsuList.get(x)" or something....
Sounds like very hacky code. Why are you using an index to get the Jutsu? Could this all be better served by some simple enumerations?
What exactly is the use of this? There's undoubtedly a better way.
...but it doesn't look like that.
Generics were introduced with Java 1.5 - it allows you to supply compile-time type declarations for collections (among other things).
An ArrayList is still a List, though
I simply don't have to cast.
I could do something like:
Does that make sense?
Your suggestion takes me a step closer. Thank you for your help!
For whatever reason, the compiler thinks that I've neglected to import 'java.lang.String' when trying to add items to the list.
I'm using Java 1.5. Should I be using the Generic data type instead?