📜  valueof 与 tostring - Java 代码示例

📅  最后修改于: 2022-03-11 14:52:24.408000             🧑  作者: Mango

代码示例1
public static void main(String args[]) {  
    String str = null;
    System.out.println(String.valueOf(str));  // This will print a String equal to "null"        
    System.out.println(str.toString()); // This will throw a NullPointerException
}