The problem I encountered when I wrote a Java file with EditPlus.
Copy Code code as follows:
Import java.util.*;
Class collection{
public static void Main (string[] args) {
Collection c1=new ArrayList (25);
C1.add (New String ("one"));
C1.add (New String ("two"));
String s= "three";
C1.add (s);
For (iterator I=c1.iterator (); I.hasnext ();)
{
System.out.println (I.next ());
}
}
}
Then look for the following reasons, which are transferred from someone else's.
This problem may occur when you are using jdk1.5 or above when compiling Java source files. (Use an unchecked or unsafe operation; recompile with-xlint:unchecked.) )
The reason is that there are some differences between the creation of the collection class in jdk1.5 and the jdk1.4, mainly the addition of generics in jdk1.5, which means that the data in the collection can be checked. Before jdk1.5, if the parameter type is not specified, the JDK 1.5 compiler reports unchecked warning because it cannot check if the given parameter is required, which does not affect running. As prompted, compilation is a specified parameter to cancel such a warning. or set the type parameters for it.
Copy Code code as follows:
List temp = new ArrayList ();
Temp.add ("1");
Temp.add ("2");
Amended to
Copy Code code as follows:
List <String> temp = new ArrayList <String> ();
Temp.add ("1");
Temp.add ("2");
Then modify the code to
Copy Code code as follows:
Import java.util.*;
Class collection{
public static void Main (string[] args) {
Collection<string> c1=new arraylist<string> (25);
C1.add (New String ("one"));
C1.add (New String ("two"));
String s= "three";
C1.add (s);
For (iterator I=c1.iterator (); I.hasnext ();)
{
System.out.println (I.next ());
}
}
}