Win a copy of Learn Java with Math: Using Fun Projects and Games this week in the Beginning Java forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Junilu Lacar
  • Martin Vashko
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Scott Selikoff
  • salvin francis
  • Piet Souris

What does it mean?

 
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What does it mean when you run your program and although it runs you have the following message on the console:
Note: *.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.

How can one get rid of it.
 
Ranch Hand
Posts: 2410
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What that means is you're probably compiling legacy code(<= JDK 1.4) with JDK >= 1.5. It means that you are probably using a collection which specifying the type that is to be held in the collection. You can try javac -source 1.4 filename
 
Keith Lynn
Ranch Hand
Posts: 2410
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm sorry. That should have said you are probably using a collection without specifying what type is to be held in the collection.
 
O Joseph
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thank you
 
Ranch Hand
Posts: 1078
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Recompile with -Xlint:unchecked and see what errors it gives you. As already mentioned the most likely culprit is using a raw Collection while compiling in 1.5.
 
O Joseph
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
the error is as follows :
warning [unchecked] unchecked call to add(E) as a member of the raw type java.util.Vector
Any suggestions
 
Ken Blair
Ranch Hand
Posts: 1078
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Firstly, unless there is some requirement that you use Vector such as working with an old API then you shouldn't be using it. You should use ArrayList insted.

Second, if you're interested in learning generics then see the section in the Java Tutorial at java.sun.com on Generics. You will need to declare the parameterized type (i.e. Vector<String> and initialize using that as well. The other option is to turn the warnings off. If you're writing valid 1.4 code and not using generics then you should be able to safely ignore the warnings.
 
straws are for suckers. tiny ads are for attractive people.
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!