• Post Reply Bookmark Topic Watch Topic
  • New Topic

ArrayList.add  RSS feed

 
Sudhakar Gaharwar
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here i added some item into ArrayList that is aList..As we know we can add only object into the ArrayList.But i want to add int value..So i have changed it by aList.add(rs.""+getInt("boat_id"));But its giving error..So pls tell me how to do that.

aList.add(rs.getString("boat_id"));//This is OK
aList.add(rs.getString(""+"boat_id"));
aList.add(rs.""+getInt("boat_id"))); //Problem

Thanks
 
Mani Ram
Ranch Hand
Posts: 1140
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Sudhakar Gaharwar:
aList.add(rs.""+getInt("boat_id"))); //Problem


You need to learn the syntax first. The above statement is not a legal one, and will obviously throw a compile time error.
It should be


There are various other ways to acheive this.
 
Sudhakar Gaharwar
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanx alot..
 
Jeff Albertson
Ranch Hand
Posts: 1780
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Some of Mani's alternatives add an Integer, others add a String. Be sure you know which is right for you, or if it doesn't matter.
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!