String str = "null";
if ( str == "null") {
System.out.println(" String value is 'null');
} else {
System.out.println(" String value is not 'null');
}
Output: " String value not 'null' "
if ( "null".equals(str)) {
System.out.println(" String value is 'null');
} else {
System.out.println(" String value is not 'null');
}
Output: " String value 'null' "
No comments:
Post a Comment