|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
I've done my program, it works but i keep getting the following when i compile:
Note: C:\Documents and Settings\Nabil\Desktop\CdStorage3.java uses unchecked or unsafe operations. Note: Recompile with -Xlint:unchecked for details. im using J Creator, wat does it mean by unchecked and unsafe operations. i dont know what some instructions mean ne chance of an explanation: catch(NumberFormatException ne){ menu=1; Iterator iter = arrayLst.iterator(); while (iter.hasNext()) array = (CdRecord)iter.next(); ne chance of tellin what these pieces of code actually do in the program below.. import java.util.*; import javax.swing.*; public class CdStorage3 { public static void main (String[] args) { CdRecord array; List arrayLst= new ArrayList(); String menu_choice; int menu; while (true) { menu_choice = JOptionPane.showInputDialog("Enter:\n 1: New CD entry\n 2: Print\n 3: Quit"); try { menu = Integer.parseInt(menu_choice); } catch(NumberFormatException ne){ menu=1; } if (menu==3) { break; } else if (menu==1) { arrayLst.add(new CdRecord()); } else if (menu==2) { Iterator iter = arrayLst.iterator(); while (iter.hasNext()) { array = (CdRecord)iter.next(); array.printCdRecord(); } break; } } } //end main }//end class class CdRecord { private String artist_name; private String album_name; private int no_of_tracks; public CdRecord () { artist_name = JOptionPane.showInputDialog("Enter Artist Name"); album_name = JOptionPane.showInputDialog("Enter Album Name"); no_of_tracks = Integer.parseInt(JOptionPane.showInputDialog("Enter Number Of Tracks")); } public void printCdRecord () { System.out.println("Artist Name: " +artist_name + "\nAlbum Name: " +album_name+"\nNo. Of Tracks: " +no_of_tracks+"\n"); } }//end class cdstorage would apreciate all and ne help. |
|
#2
|
||||
|
||||
|
I found the following explanation at http://www.ociweb.com/jnb/jnbJul2003.html
The classes that make up the Collections API will be generic compatible with the release of Java 1.5. What this means is that all classes in the Collections API have been modified to accept generic type parameters. A program that uses classes in the Collections API without generic type parameters will continue to work but the compiler will generate a warning stating that unsafe or unchecked operations are being used. |
![]() |
| Viewing: Dev Articles Community Forums > Programming > Java Development > Some code definitions and compile error??? |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|