当前位置:编程学习 > wap >>

内部类 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
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,