aspose file tools*
The moose likes Java in General and the fly likes uncheked or unsafe operations notification Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "uncheked or unsafe operations notification" Watch "uncheked or unsafe operations notification" New topic
Author

uncheked or unsafe operations notification

Fola Fadairo
Ranch Hand

Joined: Feb 16, 2004
Posts: 35
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

Joined: Mar 06, 2001
Posts: 13459

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

Joined: Dec 11, 2004
Posts: 13410

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.


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
reeti
Greenhorn

Joined: Sep 30, 2005
Posts: 4
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

Joined: Jan 10, 2002
Posts: 60053
    
  65

"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


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60053
    
  65

Not much to do with JSP, so moved to the Java in General (intermediate) forum.
Layne Lund
Ranch Hand

Joined: Dec 06, 2001
Posts: 3061
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>();


Java API Documentation
The Java Tutorial
Layne Lund
Ranch Hand

Joined: Dec 06, 2001
Posts: 3061
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
 
 
subject: uncheked or unsafe operations notification
 
Similar Threads
Xlint:unchecked
Array problem
problem with model compilation
what problem is this???
Xlint:unchecked