• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Need help on generics

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 178
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Are you using Java 4?

The code compiles fine for me. I am using Java6,Update7.
 
Sheriff
Posts: 9708
43
Android Google Web Toolkit Hibernate IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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

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.

 
Analise Ramil
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Sheriff
Posts: 9708
43
Android Google Web Toolkit Hibernate IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This is not an error. It is a warning...
 
Analise Ramil
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Ankit Garg:
This is not an error. It is a warning...



Ok Ankit! Got it, thanks.
reply
    Bookmark Topic Watch Topic
  • New Topic