unsafe operation

Please support our Java advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Mar 2006
Posts: 112
Reputation: Covinus is an unknown quantity at this point 
Solved Threads: 0
Covinus's Avatar
Covinus Covinus is offline Offline
Junior Poster

unsafe operation

 
0
  #1
Jan 9th, 2007
[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
if you cant hit 2 birds with one stone try hitting just one or you will end up with nothing at all
Reply With Quote Quick reply to this message  
Join Date: Feb 2006
Posts: 2,467
Reputation: masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of 
Solved Threads: 267
Moderator
masijade's Avatar
masijade masijade is offline Offline
Nearly a Posting Maven

Re: unsafe operation

 
0
  #2
Jan 9th, 2007
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
Java Programmer and Sun Systems Administrator

----------------------------------------------

Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.
--Brian Kernighan
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:




Views: 793 | Replies: 1
Thread Tools Search this Thread



Tag cloud for Java
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC