Search for the difference between Vector and ArrayList, and it will become clear why Vector is hardly ever the class to go for.
Originally posted by Campbell Ritchie:
He forgot to mention however, that you can never put a 1 into a List.
You couldn't in Java 1.4 and before. In Java 5 and up however, if you declare the list as a List<Integer>, then the compiler will allow it, using autoboxing.
Actually I don't think a List has a put method in the first place.
It doesn't, there are add and insert methods. put is a method of Map.
Original poster wants to do object oriented programming. The procedural nature of main has left the orignal poster trying to get out of main(). I suggest any standard demo program, one that would be approved by the OO camp and make sure there is a way to put a main in it. Then do a new on the enclosing class and show how to call instance methods on the enclosing class.
Use the class of your choice or your own authorship, as should the original poster.
[ December 09, 2007: Message edited by: Nicholas Jordan ]
Originally posted by Nicholas Jordan:
Then do a new on the enclosing class and show how to call instance methods on the enclosing class.
I beg your pardon? What does that mean? If you are going to put data into the class then instantiate it, you have either got only static data, which won't pass muster in Campbell's school of object-oriented programming, or you have lost all your data.
I think it would be best of we went back to Stan James' original and correct advice:
Medrano Ryan: Please follow Stan's advice and post something you have got whether it works or net. Round here the C++ students are taught (quite correctly) to have as little code as possible in their main() method.
show code that almost works