Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

vector and integer

 
Suka Hati
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i have below coding

outputDuration.addElement(cubaan);

cubaan is integer. outputDuration is a vector. when i tried to compile this coding i got error

addElement(java.lang.Object) in java.util.Vector cannot be applied to (int)
outputDuration.addElement(cubaan);

how to solve this error???can anybody help me
 
Yosi Hendarsjah
Ranch Hand
Posts: 166
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Look at the API docs for java.util.Vector. The method's parameter type is Object. You can wrap cubaan with java.lang.Integer.
 
Marilyn de Queiroz
Sheriff
Posts: 9065
12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
An 'int' is not an Object. You need to change your int to an Object before you can store it in a Vector.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic