内部类 newinstance failed no init ()
public class TestJsonParase extends AndroidTestCase {
public class TempClass {
int c=0 ;
public TempClass(){
}
}
public void testJsonToObject(){
String json = "{a:b,c:1}";
JSONObject object = null ;
try {
object = new JSONObject(json);
} catch (JSONException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Class<?> demo = OldInformation.class;
Object obj = null;
TempClass tempClass = null;
try {
tempClass = TempClass.class.newInstance() ;
} catch (InstantiationException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IllegalAccessException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
assertNotNull(tempClass);
}
}
这个为什么会出错呢?tempClass 为空。
补充:移动开发 , Android