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 }