Results 1 to 7 of 7
Thread: -Xlint???
- 03-08-2013, 06:40 PM #1
Member
- Join Date
- Jan 2013
- Posts
- 30
- Rep Power
- 0
-Xlint???
When compiling my project i get this kind of message:
"Note: rtype\Craft.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details."
code is :
Could someone tell me whatswrogn here?Java Code:package rtype; import java.awt.Image; import java.awt.event.KeyEvent; import java.util.ArrayList; import javax.swing.ImageIcon; public class Craft { private String craft = "craft.png"; private int dx; private int dy; private int x; private int y; private Image image; private ArrayList missiles; private final int CRAFT_SIZE = 20; public Craft() { ImageIcon ii = new ImageIcon(this.getClass().getResource(craft)); image = ii.getImage(); missiles = new ArrayList(); x = 40; y = 60; } public void move() { x += dx; y += dy; } public int getX() { return x; } public int getY() { return y; } public Image getImage() { return image; } public ArrayList getMissiles() { return missiles; } public void keyPressed(KeyEvent e) { int key = e.getKeyCode(); if (key == KeyEvent.VK_SPACE) { fire(); } if (key == KeyEvent.VK_LEFT) { dx = -1; } if (key == KeyEvent.VK_RIGHT) { dx = 1; } if (key == KeyEvent.VK_UP) { dy = -1; } if (key == KeyEvent.VK_DOWN) { dy = 1; } } public void fire() { missiles.add(new Missile(x + CRAFT_SIZE, y + CRAFT_SIZE/2)); } public void keyReleased(KeyEvent e) { int key = e.getKeyCode(); if (key == KeyEvent.VK_LEFT) { dx = 0; } if (key == KeyEvent.VK_RIGHT) { dx = 0; } if (key == KeyEvent.VK_UP) { dy = 0; } if (key == KeyEvent.VK_DOWN) { dy = 0; } } }
- 03-08-2013, 06:43 PM #2
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,408
- Blog Entries
- 7
- Rep Power
- 17
Re: -Xlint???
You're using a 'raw' type ArrayList and the compiler warns against it.
kind regards,
JosWhen people rob a bank they get a penalty; when banks rob people they get a bonus.
- 03-08-2013, 07:12 PM #3
Member
- Join Date
- Jan 2013
- Posts
- 30
- Rep Power
- 0
Re: -Xlint???
im following zetcode tutorial and there it says do it this way. What would be yor suggestion to fix it?
- 03-08-2013, 07:42 PM #4
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,408
- Blog Entries
- 7
- Rep Power
- 17
- 03-08-2013, 07:48 PM #5
Senior Member
- Join Date
- Jan 2013
- Location
- United States
- Posts
- 688
- Rep Power
- 1
Re: -Xlint???
From looking at your code, it should be
Java Code:private ArrayList<Missile> missiles; // since Java 1.5 private final int CRAFT_SIZE = 20; public Craft() { ImageIcon ii = new ImageIcon(this.getClass().getResource(craft)); image = ii.getImage(); missiles = new ArrayList<Missile>(); x = 40; y = 60; } ... public ArrayList<Missile> getMissiles() { return missiles; }
Regards,
JimLast edited by jim829; 03-08-2013 at 07:49 PM. Reason: too late again!!
The Java™ Tutorial
YAT -- Yet Another Typo
- 03-08-2013, 08:59 PM #6
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,408
- Blog Entries
- 7
- Rep Power
- 17
Re: -Xlint???
When people rob a bank they get a penalty; when banks rob people they get a bonus.
- 03-08-2013, 09:49 PM #7
Member
- Join Date
- Jan 2013
- Posts
- 30
- Rep Power
- 0
Similar Threads
-
Using or overriding a deprecated API; Recompile with -Xlint:deprecation for details
By Nazneen Ali in forum New To JavaReplies: 24Last Post: 07-29-2011, 04:53 PM -
-Xlint / -Deprecation Error
By seejay in forum New To JavaReplies: 3Last Post: 01-14-2011, 11:25 PM -
xlint full form
By java4susant in forum New To JavaReplies: 0Last Post: 10-27-2010, 02:08 AM -
unchecked or unsafe operations-Recompile with -Xlint
By pronetin in forum Advanced JavaReplies: 15Last Post: 05-31-2010, 05:41 PM -
Xlint in build.xml not working
By sunjavaboy in forum EclipseReplies: 0Last Post: 06-23-2008, 01:35 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks