| Author |
what's wrong with this code
|
joseph okon
Ranch Hand
Joined: Dec 07, 2004
Posts: 63
|
|
Why is this code:- Vector v = new Vector(); try { Statement stmt = connection.createStatement(); ResultSet rs = stmt.executeQuery("SELECT acc_id FROM mytable"); while(rs.next()) { v.addElement(rs.getString("acc_id")); } rs.close(); giving me this warning:- warning: [unchecked] unchecked call to add(E) as a member of the raw type java.util.Vector v.addElement(rs.getString("acc_id")); please can someone explain to me why and what to do next joe
|
 |
Campbell Ritchie
Sheriff
Joined: Oct 13, 2005
Posts: 32675
|
|
Look at the Generics part of the Java Tutorial. The last part where it says "unchecked warnings" will help you. Briefly, since Java5, Vector has been a generic class. Read the tutorial for more details. And don't use Vector. Use ArrayList instead, and declare the type of the object as java.util.List.
|
 |
Jesper de Jong
Java Cowboy
Bartender
Joined: Aug 16, 2005
Posts: 12921
|
|
|
Please do not post the same question multiple times.
|
Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
|
 |
 |
|
|
subject: what's wrong with this code
|
|
|