Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

valueof vs tostring

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
} 
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #valueof #tostring
ADD COMMENT
Topic
Name
6+8 =