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

uses unsafe or unchecked operations

Pauldon
Greenhorn

Joined: Apr 11, 2006
Posts: 19
Anyone have a clue whats going on here i keep getting unchecked or unsafe operations. Tried compiling it in command window. Still dont know what the problem is. Thanks.

Scott Dunbar
Ranch Hand

Joined: Sep 23, 2004
Posts: 245
Well, we're missing the code to Move.java but generally casts are not a good idea since the inclusion of generics in the language. You're likely to get better results by doing:



<a href="http://forums.hotjoe.com/forums/list.page" target="_blank" rel="nofollow">Java forums using Java software</a> - Come and help get them started.
Pauldon
Greenhorn

Joined: Apr 11, 2006
Posts: 19
Yeah that has helped thanks, the only problem i have left is with adding a new move. Here is the move class.

Its the move.zplane.add(new Move(n,r,cc)); its not liking.

Sorry to bother you. Cheers.


Scott Dunbar
Ranch Hand

Joined: Sep 23, 2004
Posts: 245
Same problem - declare zplane as:



and you'll be in better shape.

The problem you're having is that things like ArrayList and the other collections always took and returned Object's in 1.4 and below. Now you can strongly type them by specifing that, for example, zplain is an ArrayList of Move objects. Nothing else will be allowed to be put in or returned from the ArrayList. The error and warnings are to let you know that there is a safer way of doing things in Java 1.5/5.0.
Tony Morris
Ranch Hand

Joined: Sep 24, 2003
Posts: 1608
Your original code will compile without warning using -source 1.4 (and therefore, -target 1.4). Therefore, the question is "which VM are you targetting?" If you are targetting 1.5, you will need to become familiar with 1.5 language features, and in this specific case generics.

If you are not targetting 1.5 - but some lower VM (e.g. 1.4) - then you can delay learning these new language features for now.

Simply, if you are using/targetting 1.5, you need to know what 1.5 is.


Tony Morris
Java Q&A (FAQ, Trivia)
Tony Morris
Ranch Hand

Joined: Sep 24, 2003
Posts: 1608
Originally posted by Tony Morris:
Your original code will compile by warning using -source 1.4 (and therefore, -target 1.4). Therefore, the question is "which VM are you targetting?" If you are targetting 1.5, you will need to become familiar with 1.5 language features, and in this specific case generics.

If you are not targetting 1.5 - but some lower VM (e.g. 1.4) - then you can delay learning these new language features for now.

Simply, if you are using/targetting 1.5, you need to know what 1.5 is.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: uses unsafe or unchecked operations
 
Similar Threads
GUI for RMI
K&B page398
AOOB exception in my CODE-PLEASE HELP!
Knight's tour
Need help on two compile errors