再问一个今天的面试题# Java - 爪哇娇娃
s*i
1 楼
关于java reflection的
Suppose class ClassName immplements runnable interface. Write a function
which returns a thread that attached with this class, taking the class name
string as argument.
我这么写的:
public Thread myFunction (String s) {
Thread t=null;
try {
Object o = Class.forName(s).newInstance();
t = new Thread((Runnable)o);
}
catch(Exception e ){
Suppose class ClassName immplements runnable interface. Write a function
which returns a thread that attached with this class, taking the class name
string as argument.
我这么写的:
public Thread myFunction (String s) {
Thread t=null;
try {
Object o = Class.forName(s).newInstance();
t = new Thread((Runnable)o);
}
catch(Exception e ){