Thread: Quiz Time
View Single Post
  #168 (permalink)  
Old 05-16-2008, 06:28 AM
Jesdisciple Jesdisciple is offline
Member
 
Join Date: May 2008
Posts: 22
Jesdisciple is on a distinguished road
What's the result (output or compile/runtime error/exception) of this?
Code:
class B { String value; B(String value){ this.value = value; } public String toString(){ return value; } static void test(A<? extends Object> a){ a.set(new B("foo")); System.out.println(a.get()); } public static void main(String[] args){ A<B> a = new A<B>(); test(a); } } class A<T> { private T o; void set(T o){ this.o = o; } T get(){ return o; } }
Reply With Quote