• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

objects and Vectors

 
Donna Bachner
Ranch Hand
Posts: 109
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How come when you put an Integer into a vector it comes out as an object. can I change this. I am trying to do math on the numbers in the vector.
 
Garrett Rowe
Ranch Hand
Posts: 1296
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Depends... If you're using Java 1.5 you can use the paramterized type. Even if you're not, you can put those Vectors away. Use an ArrayList instead.
 
Donna Bachner
Ranch Hand
Posts: 109
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks,I'll try that and let you know how it works.
 
Henry Wong
author
Marshal
Pie
Posts: 20820
75
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Even if you are not using Java 5, you can always cast it back to an Integer. It may be an Object reference, but it should be the object that you stored, which means it should be an Integer.

Henry
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic