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

unchecked or unsafe operations

Niyas Ahmed Sheikh
Ranch Hand

Joined: Jun 15, 2005
Posts: 129
Hi,

While I am trying to compile the java prgoram, I am getting the following error:



What is that error? How to resolve it? Pls Help.
Steffen Reinhard
Greenhorn

Joined: Jun 13, 2005
Posts: 19
I've seen a couple of these, too ... Basically, this isn't exactly an error message, it's just a javac version 1.5.something compiler warning. Recompiling with "-Xlint:unchecked" won't make things much clearer. I did. It didn't.

As you are not dealing with a compile-time error, the warning won't keep your code from running (as long as you don't have any
real errors in your code). If the chatty compiler messages keep bothering you, consider switching back to good old SDK 1.4 (if you don't need any of the additional features of Java 1.5). To do this you will have to reconfigure your IDE. If you don't use an IDE you will have to set a couple of environment variables (taking for granted you still have some SDK 1.4.something stuffed away on your system, otherwise just download and install according to instructions given for your os).

I hope this will help.

Cheers -

Steffen
[ August 03, 2005: Message edited by: Steffen Reinhard ]
Niyas Ahmed Sheikh
Ranch Hand

Joined: Jun 15, 2005
Posts: 129
So... what is the next step for this?
Steve Morrow
Ranch Hand

Joined: May 22, 2003
Posts: 657

So... what is the next step for this?


Generics in the Java� Programming Language
Java Generics FAQs, by Angelika Langer
Stuart Gray
Ranch Hand

Joined: Apr 21, 2005
Posts: 410
Yes, you should definitely read those links and try to learn some more about Generics. Although Steffen is right that the messages are only warnings rather than errors, generics are quite a useful tool to provide additional compile-time type safety.
Philip Heller
author
Ranch Hand

Joined: Oct 24, 2000
Posts: 119
Generics are a new thing in release 5.0, and if you don't use them then sometimes the compiles wags a finger at you. (No, not that finger!)

To understand generics ... well, to scrath the surface ... think of the Vector class. You used to use vectors like this:



Usually vectors (and other collections) are homogeneous. That is, even though they can contain data of all different types, they most often don't. A common bug is adding the wrong thing to the wrong collection, like adding to instead of to . Up to now, that bug has been really hard to find, because you only get symptons when you retrieve the contents of , far from the source of the bug.

With generics, you can declare that a certain vector only contains strings (or that a certain set only contains buttons, etc.). You do it like this:



Now is only allowed to contain strings. If you try to add something incompatible, the compiler will squawk. A compile-time bug is a zillion times easier to fix than a run-time bug.

Much much more on this in Chapter 8 of "Complete Java 2 Certification".


-- Phil


Consultant to SCJP team.<br />Co-designer of SCJD exam.<br />Co-author of "Complete Java 2 Certification Study Guide".<br />Author of "Ground-Up Java".
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: unchecked or unsafe operations