| Author |
Need help on generics
|
Analise Ramil
Greenhorn
Joined: Sep 02, 2008
Posts: 4
|
|
Can anyone please explain me why I am getting these errors and how I could fix it? *************************************************************** AList.java:23: type ArrayList does not take parameters List<Integer> iL = new ArrayList<Integer>(); ^ .\ArrayList.java:22: incompatible types found : ArrayList required: java.util.List<java.lang.Integer> List<Integer> iL = new ArrayList(); ^ Note: Some input files use unchecked or unsafe operations. Note: Recompile with -Xlint:unchecked for details. 2 errors *************************************************************** The code below came from S&B book page 559, with little modification. Thanks in advance.
|
 |
Rekha Srinath
Ranch Hand
Joined: Sep 13, 2008
Posts: 178
|
|
Are you using Java 4? The code compiles fine for me. I am using Java6,Update7.
|
 |
Ankit Garg
Saloon Keeper
Joined: Aug 03, 2008
Posts: 9189
|
|
Hi Analise! Welcome to javaranch. As far as your problem goes, is the code you put here exactly what you wrote. I feel that you named your own class as ArrayList. This can be seen from your error too
|
SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
|
 |
Analise Ramil
Greenhorn
Joined: Sep 02, 2008
Posts: 4
|
|
Hello! Thanks for your reply. Im using java java 5. Hmmm I still can't have it working. I named the class originally as ArrayList.java but later renamed it. I will try to restart my pc and see if I can get this work. Thanks again.
|
 |
Analise Ramil
Greenhorn
Joined: Sep 02, 2008
Posts: 4
|
|
Hello again. I got the code working now. I deleted ArrayList.java from my drive, the original file name. Thanks for pointing it out to me Ankit. However, I am getting compiler note as follows: ************************************** c:\JavaWork>javac AList.java Note: AList.java uses unchecked or unsafe operations. Note: Recompile with -Xlint:unchecked for details. ************************************** Are you getting the same note Rekha? Can anyone explain how and if there is something I can do to get a clean compilation (no note).
|
 |
Ankit Garg
Saloon Keeper
Joined: Aug 03, 2008
Posts: 9189
|
|
|
This is not an error. It is a warning...
|
 |
Analise Ramil
Greenhorn
Joined: Sep 02, 2008
Posts: 4
|
|
Originally posted by Ankit Garg: This is not an error. It is a warning...
Ok Ankit! Got it, thanks.
|
 |
 |
|
|
subject: Need help on generics
|
|
|