Kevin
Kevin

Reputation: 3431

Why am I getting an unchecked warning here?

Dataset extends ArrayList.

Dataset<Pair<SRGB>> data = new Dataset<Pair<SRGB>>();
Statement stmt = this.conn.createStatement();
ResultSet rs = stmt.executeQuery(sql);
while (rs.next()) {
    data.add(new Pair<SRGB>(SRGB.create(rs.getString(2)),
                            SRGB.create(rs.getString(3)),
                            rs.getDouble(1),
                            rs.getInt(4)));
}
warning: [unchecked] unchecked call to add(E) as a member of the raw type java.util.ArrayList

Upvotes: 1

Views: 144

Answers (2)

cklab
cklab

Reputation: 3771

Chances are you've declared your Dataset class to extend ArrayList without any generic type.

Make sure your Dataset class extends ArrayList like so:

class Dataset<T> extends ArrayList<T> {
    // ...
}

And not

class Dataset<T> extends ArrayList {
    // ...
}

Upvotes: 5

marc wellman
marc wellman

Reputation: 5886

maybe this documentation will help you

I know this was not your question but did you know that you can suppress these warnings with an annotation :

@SuppressWarnings("unchecked")

Upvotes: -1

Related Questions