aspose file tools*
The moose likes Beginning Java and the fly likes JDK 1.5 Type Safety warning Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "JDK 1.5 Type Safety warning" Watch "JDK 1.5 Type Safety warning" New topic
Author

JDK 1.5 Type Safety warning

Saket Barve
Ranch Hand

Joined: Dec 19, 2002
Posts: 229
Hello,

I am getting type safety warning in my code, relevant part of which is reproduced below:



The last line gives a warning stating:
"The method add(Object) belongs to the raw type ArrayList. References to generic type ArrayList<E> should be parameterized."

How does one get around this warning? The Quick Fix option in Eclipse doesn't seem to come up with very helpful options.

Saket
[ September 04, 2006: Message edited by: Saket Barve ]
Keith Lynn
Ranch Hand

Joined: Feb 07, 2005
Posts: 2367
Originally posted by Saket Barve:
Hello,

I am getting type safety warning in my code, relevant part of which is reproduced below:



The last line gives a warning stating:
"The method add(Object) belongs to the raw type ArrayList. References to generic type ArrayList<E> should be parameterized."

How does one get around this warning? The Quick Fix option in Eclipse doesn't seem to come up with very helpful options.

Saket

[ September 04, 2006: Message edited by: Saket Barve ]


Instead of making the type of itemAddArrayList the raw type ArrayList, make it the same parameterized type you use on the right.
Saket Barve
Ranch Hand

Joined: Dec 19, 2002
Posts: 229
Thanks for the reply Keith, the issue is now resolved.
[ September 04, 2006: Message edited by: Saket Barve ]
Srinivas Kalvala
Ranch Hand

Joined: Oct 20, 2005
Posts: 257

Hello,

To avoid -Xlint:unchecked,

List<Type> Obj=new ArrayList<Type>();

Class<Type> Obj=new Class<Type>();
Class<Type> Obj=new SubClass<Type>();

Interface<Type> Obj=new ConClass<Type>();

One can use ? ( wild char) in Left hand side of = ( Declaration ) but not in Right hand side.
 
wood burning stoves
 
subject: JDK 1.5 Type Safety warning