• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

uncheked or unsafe operations notification

 
Fola Fadairo
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I have the following code..



The code compiles, but with the following message..


Note: C:\jspfiles\beerV1\src\com\example\model\BeerExpert.java uses unchecked or unsafe operations.

Note: Recompile with -Xlint:unchecked for details.


I recompiled with the -Xlint:unchecked flag. The problem lies with the "add" method of the ArrayList. I changed the method specification to



but I get the same message..

Can anyone help with solving the mystery?
Thanks.
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is a Java 1.5 thing. Just ignore it for now, you can safely continue with learning JSPs and have a look at the differences in Java 1.5 later on
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can squelsh that by adding the following switch when running javac:


Of course it will blow up if you're using 1.5 features but I doubt there are any in that book.
 
reeti
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi

i also faced the same problem i solved it with use of <generics>

try this List<String> a=new <String>ArrayList()
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64959
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"reeti",

There aren't many rules that you need to worry about here on the Ranch, but one that we take very seriously regards the use of proper names. Please take a look at the JavaRanch Naming Policy and adjust your display name to match it.

In particular, your display name must be a first and a last name separated by a space character, and must not be obviously fictitious.

Thanks!
bear
Forum Bartender
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64959
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not much to do with JSP, so moved to the Java in General (intermediate) forum.
 
Layne Lund
Ranch Hand
Posts: 3061
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by reeti:
hi

i also faced the same problem i solved it with use of <generics>

try this List<String> a=new <String>ArrayList()


It should be

List<String> a=new ArrayList<String>();
 
Layne Lund
Ranch Hand
Posts: 3061
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Fola Fadairo:

but I get the same message..

Can anyone help with solving the mystery?
Thanks.


The message is probably similar, but it is not the same. There are more details that tell you exactly where the "unchecked or unsafe operation" occurs. As others have pointed out, this is because you are not using generics, which are a new feature in Java 5.0. If you are interested in learning more about generics and how they are used in the Collections API, I suggest you google for more information.

Layne
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic