S
Stefan Ram
I used this piece of code to find the return type of the
method "f" in the interface "C" under Java 1.6.
interface A { java.lang.Object f(); }
interface B { B f(); }
interface C extends A, B {}
public class Main
{ public static void main( final java.lang.String[] args )
{ java.lang.reflect.Method method = null; try
{ method = C.class.getMethod( "f",( java.lang.Class[] )null ); }
catch( final java.lang.NoSuchMethodException noSuchMethodException )
{ throw new java.lang.RuntimeException( noSuchMethodException ); }
java.lang.System.out.println( method.getReturnType() ); }}
A reader of this post might try to predict the outcome
without actually running or compiling it. -- The range of
possible predictions also includes »It will not compile,«
or »It will produce a run-time error«.
method "f" in the interface "C" under Java 1.6.
interface A { java.lang.Object f(); }
interface B { B f(); }
interface C extends A, B {}
public class Main
{ public static void main( final java.lang.String[] args )
{ java.lang.reflect.Method method = null; try
{ method = C.class.getMethod( "f",( java.lang.Class[] )null ); }
catch( final java.lang.NoSuchMethodException noSuchMethodException )
{ throw new java.lang.RuntimeException( noSuchMethodException ); }
java.lang.System.out.println( method.getReturnType() ); }}
A reader of this post might try to predict the outcome
without actually running or compiling it. -- The range of
possible predictions also includes »It will not compile,«
or »It will produce a run-time error«.