• 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
  • Liutauras Vilda
  • Tim Cooke
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Devaka Cooray
  • Ron McLeod
  • paul wheaton
Saloon Keepers:
  • Tim Moores
  • Piet Souris
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Frits Walraven
  • Scott Selikoff

uses unsafe or unchecked operations

 
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.

 
Ranch Hand
Posts: 245
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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:

 
Pauldon
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 245
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 1608
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Ranch Hand
Posts: 1608
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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.

 
That is a really big piece of pie for such a tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic