I have no idea how to fix the compile warning.

Y:\Development\Java\Mileage\Mileage\src\my\Mileage\MileageUI.java:296: warning: [unchecked] unchecked call to add(E) as a member of the raw type java.util.Vector

dataList.add(doctorData);

Appreciate some suggestions. Thanks..

Recommended Answers

All 7 Replies

Post the segment of your code where you get your warning and any other relevant portion of your code. In code tags.

Can you please post your code so we can see the problem in context. Thanks.

*Sorry BestJewSinceJC I didnt realize you already asked the same question until after I posted ;) *

Here's the code snip

Vector dataList = new Vector();
try {
            while (resultSet.next()) {

                // Save the data for loading the comboBox
                doctorData = new DoctorData();                      // Create an data object
                doctorData.setName(resultSet.getString("name"));    // Save the name in position 1
                doctorData.setTitle(resultSet.getString("title"));  // Save the title
                doctorData.setDoctorID(resultSet.getLong("doctorid"));  // Save the primary key

//This is line that is giving the compile warning message
                dataList.add(doctorData);
            }
        } catch (SQLException e) {
            e.printStackTrace();
}

Isn't Vector a generic class? You would have to define the generic type when you create the new vector.
Judging by your code you would want something like:

Vector<DoctorData> dataList = new Vector<DoctorData();

Does that fix the problem? ...I'm pretty sure vector is generic...

That fixed the problem. Now I have NO idea what "generic classes" are. So I need to do some googling.

Thanks....

Isn't Vector a generic class? You would have to define the generic type when you create the new vector.
Judging by your code you would want something like:

Vector<DoctorData> dataList = new Vector<DoctorData();

Does that fix the problem? ...I'm pretty sure vector is generic...

Yeah, it is. That's the error I expected to see, but you never can be too sure without seeing the code.

@OP, you might want to take a look at this.

http://java.sun.com/j2se/1.5.0/docs/guide/language/generics.html

Generic classes can be pretty tricky, but if you are only using them and not actually implementing them you don't need to understand all the messy details. Basically they are classes that can operate on different types of data, so you need to define what type of data you want them to work on.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.