• 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:
  • Campbell Ritchie
  • Liutauras Vilda
  • Tim Cooke
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Devaka Cooray
  • Ron McLeod
  • paul wheaton
Saloon Keepers:
  • Tim Moores
  • Piet Souris
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Frits Walraven
  • Scott Selikoff

Warnings after compiling program using Generics

 
Ranch Hand
Posts: 276
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I have made my first program using Generic .It gets compiled with the following warnings:

GenericFirst.java:18: warning: [unchecked] unchecked call to add(E) as a member
of the raw type java.util.List
list.add("Hi!");
^
GenericFirst.java:19: warning: [unchecked] unchecked call to add(E) as a member
of the raw type java.util.List
list.add(42);


I am not able to understand what dos it want to say??

So please let me know what these warnings indicate & how to remove that??
 
author and iconoclast
Posts: 24204
44
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The problem is that in this code you've ignored generics. The error message is letting you know that you've created a List that's not parameterized -- a "pre-generics" list that isn't type-safe. Java won't let you do this without warnings anymore.

Do you understand what I'm saying?
 
You showed up just in time for the waffles! And this tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic