• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

OOP-2 and Compiler Error(Warning)?

 
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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!
 
Sheriff
Posts: 9109
12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 9109
12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes, any of the Collections including Maps, Lists and Sets.
 
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 9109
12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 9109
12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Does avoiding autoboxing give you a warning about unchecked or unsafe operations? I think not.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic