Why does String.valueOf(null) throw a NullPointerException?

http://stackoverflow.com/questions/3131865/why-does-string-valueofnull-throw-a-nullpointerexception

 

 

Object o1=new char[3];//ok
char []c2=new Object();//編譯錯誤

 

 

   public static String valueOf(Object obj) {
    return (obj == null) ? "null" : obj.toString();
    }

 

 

 

    public static String valueOf(char data[]) {
    return new String(data);
    }

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章