File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

OOP-2 and Compiler Error(Warning)?

 
Matt Fry
Ranch Hand
Posts: 60
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 9059
12
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Matt Fry
Ranch Hand
Posts: 60
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 9059
12
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, any of the Collections including Maps, Lists and Sets.
 
Vladimir Nesov
Greenhorn
Posts: 20
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Or tha fact that you explicitly write Integer(50) instead of writing just 50 and letting autoboxing do the rest.
 
Marilyn de Queiroz
Sheriff
Posts: 9059
12
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 20
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 9059
12
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Does avoiding autoboxing give you a warning about unchecked or unsafe operations? I think not.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic