File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Cattle Drive and the fly likes OOP-2 and Compiler Error(Warning)? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » This Site » Cattle Drive
Bookmark "OOP-2 and Compiler Error(Warning)?" Watch "OOP-2 and Compiler Error(Warning)?" New topic
Author

OOP-2 and Compiler Error(Warning)?

Matt Fry
Ranch Hand

Joined: Mar 06, 2006
Posts: 60
When I compile my NaturalLanguageMultiply I get a warning telling me that "Note: NaturalLanguageMultiply.java uses unsafe or unchecked operations. Note: Recompile with -Xlint for details."

It seems to not like lines like this "myHash.put( "ninety" , new Integer (90) ) ; " Am I doing something wrong that might cause me problems down the road? Since it's just a warning, the program still compiles and runs, but I know somethings not right here.

Thanks!
Marilyn de Queiroz
Sheriff

Joined: Jul 22, 2000
Posts: 9046
    
  10
It's not a problem. Because you are using a java 5 compiler to compile code that is written for java 4, it gives you a warning. As an experiment, try compiling using javac -source 1.4 and see if you get the same warnings.


JavaBeginnersFaq
"Yesterday is history, tomorrow is a mystery, and today is a gift; that's why they call it the present." Eleanor Roosevelt
Matt Fry
Ranch Hand

Joined: Mar 06, 2006
Posts: 60
Thanks for the reply, Marilyn! And as ususal, you're right and compiling w/ -source 1.4 produced no errors.

Now, another question, you said I'm writing code for Java 4. What "feature" makes this Java 4 code and not Java 5. Is it the HashMap?

Thanks again!
Marilyn de Queiroz
Sheriff

Joined: Jul 22, 2000
Posts: 9046
    
  10
Yes, any of the Collections including Maps, Lists and Sets.
Vladimir Nesov
Greenhorn

Joined: Jun 18, 2006
Posts: 20
Or tha fact that you explicitly write Integer(50) instead of writing just 50 and letting autoboxing do the rest.
Marilyn de Queiroz
Sheriff

Joined: Jul 22, 2000
Posts: 9046
    
  10
Vladimir,

Welcome to the Cattle Drive forum. Thanks for the input, but we're still using java 1.4 code here in the Cattle Drive. There is no autoboxing in jdk1.4.
Vladimir Nesov
Greenhorn

Joined: Jun 18, 2006
Posts: 20
Thanks, I'll keep it in mind, though it's all the same as an answer to 'why Java 5 compiler gives a warning?".
[ July 02, 2006: Message edited by: Vladimir Nesov ]
Marilyn de Queiroz
Sheriff

Joined: Jul 22, 2000
Posts: 9046
    
  10
Does avoiding autoboxing give you a warning about unchecked or unsafe operations? I think not.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: OOP-2 and Compiler Error(Warning)?