public class Test { public static void main(String[] args) {
Collection c = new ArrayList(); c.add("hello"); Name<String,String> name1 = new Name<String,String>("f1","l1");!!!!!!!!! c.add(name1); c.add(new Integer(100)); System.out.println(c.size()); System.out.println(c); }
class Name<F,L> { F firstName; L lastName;
public Name( F firstName1, L lastName1) { firstName = firstName1; lastName = lastName1; }
F getfirstName() { return firstName; }
L getlastName() { return lastName; }
} }
------解决方案--------------------
Java code
import java.util.*;
public class Test {
public static void main(String[] args) {
Collection c = new ArrayList();
c.add("hello");
Name<String,String> name1 = new Name<String,String>("f1","l1");
c.add(name1);
c.add(new Integer(100));
System.out.println(c.size());
System.out.println(c);
}
}
class Name<F,L> {
F firstName;
L lastName;
public Name( F firstName1, L lastName1) {
firstName = firstName1;
lastName = lastName1;
}
F getfirstName() {
return firstName;
}
L getlastName() {
return lastName;
}
}
------解决方案-------------------- 哎,呵呵!这样的的小错误不容易发现啊!就是{}的问题!
------解决方案--------------------