日期:2014-05-20 浏览次数:20682 次
public class Parcel { public Contents contents() { return new Contents() { private int i = 50; public int value() { return i; } }; } public static void main(String[] args) { Parcel p = new Parcel(); Contents c = p.contents(); } }
------解决方案--------------------
lz比较输出
public static void main(String[] args){ List list = new List() { private int i = 50; public int value() { return i; } public boolean add(Object e) { return false; } public void add(int index, Object element) { } public boolean addAll(Collection c) { return false; } public boolean addAll(int index, Collection c) { return false; } public void clear() { } public boolean contains(Object o) { return false; } public boolean containsAll(Collection c) { return false; } public Object get(int index) { return null; } public int indexOf(Object o) { return 0; } public boolean isEmpty() { return false; } public Iterator iterator() { return null; } public int lastIndexOf(Object o) { return 0; } public ListIterator listIterator() { return null; } public ListIterator listIterator(int index) { return null; } public boolean remove(Object o) { return false; } public Object remove(int index) { return null; } public boolean removeAll(Collection c) { return false; } public boolean retainAll(Collection c) { return false; } public Object set(int index, Object element) { return null; } public int size() { return 0; } public List subList(int fromIndex, int toIndex) { return null; } public Object[] toArray() { return null; } public Object[] toArray(Object[] a) { return null; } }; System.out.println(new ArrayList().getClass().getName()); System.out.println(list.getClass().getName()); }
------解决方案--------------------