943,937 Members | Top Members by Rank

Ad:
  • Java Discussion Thread
  • Unsolved
  • Views: 885
  • Java RSS
Jan 9th, 2007
0

unsafe operation

Expand Post »
[code=java]
import java.util.*;

public class al{

public static void main(String[] args){
List l = new ArrayList();

Object a = "hello";
l.add(a);
l.add("asdasd");
l.add("hgdfsdfshjk");
System.out.println(l.isEmpty()+"");
System.out.println(l.get(0));
for(int i=0;i<l.size();i++){
String b = (String)l.get(i);
System.out.println(b);
}




}
}[code]

i still havent figured out how to solve the warning it gives. can someone esplain to me the warning and maybe you could teach me how to properly use collections.

thanks
Similar Threads
Reputation Points: 31
Solved Threads: 0
Junior Poster
Covinus is offline Offline
112 posts
since Mar 2006
Jan 9th, 2007
0

Re: unsafe operation

If you have JDK 1.5 it is because you are not using Generics.

Read about Generics in the New Features portion of the Java SE 5 documentation on Sun.

http://java.sun.com/j2se/1.5.0/docs/index.html
Moderator
Reputation Points: 1471
Solved Threads: 490
Industrious Poster
masijade is offline Offline
4,043 posts
since Feb 2006

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Java Forum Timeline: Not able to Display image on canvas, want to create game.
Next Thread in Java Forum Timeline: web services using REST





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC