This week's book giveaway is in the Android forum.
We're giving away four copies of Head First Android and have David & Dawn Griffiths on-line!
See this thread for details.
Win a copy of Head First Android this week in the Android forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Jesse Silverman
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Al Hobbs
  • salvin francis

JDK 1.5 Type Safety warning

 
Ranch Hand
Posts: 237
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
 
Ranch Hand
Posts: 2412
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 237
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the reply Keith, the issue is now resolved.
[ September 04, 2006: Message edited by: Saket Barve ]
 
Ranch Hand
Posts: 257
Hibernate Firefox Browser Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic