H
hiwa
How could we 'clean up'(no ct error, no ct warning, no rt error nor
exception)
the following code? I tried everything conceivable and failed in all of
them.
------------------
import java.util.*;
import java.lang.reflect.*;
public class GetMethod{
public static void main(String[] args) {
Object obj = null;
Class<Hashtable> clazz = Hashtable.class;
Class<Class> claxx = Class.class;
try {
Method method = claxx.getMethod("newInstance");
obj = method.invoke(clazz);
}
catch (Exception e) {
e.printStackTrace();
}
Hashtable<String,String> ht = (Hashtable<String,String>)obj;
ht.put("foo", "bar");
System.out.println(ht.get("foo"));
}
}
-----------------------------------------------------------------------
exception)
the following code? I tried everything conceivable and failed in all of
them.
------------------
import java.util.*;
import java.lang.reflect.*;
public class GetMethod{
public static void main(String[] args) {
Object obj = null;
Class<Hashtable> clazz = Hashtable.class;
Class<Class> claxx = Class.class;
try {
Method method = claxx.getMethod("newInstance");
obj = method.invoke(clazz);
}
catch (Exception e) {
e.printStackTrace();
}
Hashtable<String,String> ht = (Hashtable<String,String>)obj;
ht.put("foo", "bar");
System.out.println(ht.get("foo"));
}
}
-----------------------------------------------------------------------