Answers for "valueof vs tostring"

0

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
}
Posted by: Guest on July-06-2020

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language