Java vector warning

I'm not sure what's wrong with my code

public Vector blob (Pixel px)
{
    Vector v = new Vector();

    Point p = new Point(px.getX(),px.getY());
    v.add(p);

    return v;
}

I got the following: warning: [unselected] did not choose to call add (E) as a member of the original type Vector.

v.add(P);

Where e is a type variable: e extends the object declared in the vector class

Through the API, the add function takes an object as a param. I clearly explained this before. What's the idea?

Solution

Generic!!! You must specify the object type for the contents of the vector

Vector<Point> v=new Vector<Point>()
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>