public void f2(final int a ,final User u) { a=15; //error u.setPassWord("sdf"); //correct u=new User(); //error System.out.println("类b中的f2被调用了"); }
import java.util.ArrayList; import java.util.List; public class ListWrapper<E> { private final List<E> list; private final int a=15; public ListWrapper(){ list = new ArrayList<E>(); // a=10; } public boolean contains(E e){ return list.contains(e); } public void add(E e){ list.add(e); } public void remove(E e){ list.remove(e); } public static void main(String[] args){ ListWrapper<Person> list=new ListWrapper<Person>(); Person a=new Person(); Person b=new Person(); list.add(a); System.out.println(list.contains(a)); list.remove(a); } }
原文地址:http://blog.csdn.net/dlf123321/article/details/44493691