| | |
unsafe operation
Please support our Java advertiser: Programming Forums - DaniWeb Sister Site
![]() |
[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
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
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
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
----------------------------------------------
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
![]() |
Similar Threads
- EOL is not working and uncheck or unsafe operation (Java)
- Macromedia Flash Player stopped an unsafe operation (Viruses, Spyware and other Nasties)
Other Threads in the Java Forum
- Previous Thread: Not able to Display image on canvas, want to create game.
- Next Thread: web services using REST
Views: 793 | Replies: 1
| Thread Tools | Search this Thread |
Tag cloud for Java
3d @param affinetransform android api apple applet application arc arguments array arrays automation binary bluetooth byte c# chat class classes click client code compare component corrupted database detection draw eclipse error event exception file fractal game givemetehcodez graphics gui guitesting helpwithhomework html ide image input integer j2me java java.xls javaprojects jmf jni jpanel julia keytool linux list loop map method methods mobile netbeans newbie number object oracle os pong print problem producer program programming project projectideas read recursion reflection replaysolutions rim scanner screen server set size sms socket sort sql string swing terminal test threads time transfer tree web windows






