public boolean isEmpty() |
package java like ; public class Test14 { public static void main(String[] args) { String str1 = ""; String str2 = "java like "; System.out.println(str1.isEmpty()); System.out.println(str2.isEmpty()); } } |
true false |
package java like ; public class Test14 { public static void main(String[] args) { String str1 = null; System.out.println(str1.isEmpty()); } } |
Exception in thread "main" java.lang.NullPointerException at java like .Test14.main(Test14.java:8) |
package java like ; public class Test15 { public static void main(String[] args) { String str = null; if (str == null) System.out.println("String is null"); else if (str != null) System.out.println("String is not null"); } } |
String is null |
package java like ; public class Test14 { public static void main(String[] args) { String str1 = null; String str2 = "www.javapro.ir"; if (str1 == null || str1.isEmpty()) { System.out.println("String str1 is empty or null"); } else { System.out.println(str1); } if (str2 == null || str2.isEmpty()) { System.out.println("String str2 is empty or null"); } else { System.out.println(str2); } } } |
String str1 is empty or null www.javapro.ir |
سایت جاواپرو با هدف تولید محتوای آموزشی با کیفیت رایگان در زمینه برنامه نویسی جاوا و اندروید فعالیت خود را در سال 1395 شروع کرد.امیدواریم بتوانیم دامنه گسترده تری از موضوعات پر نیاز در زمینه برنامه نویسی جاوا و اندروید را البته با حمایت شما پوشش دهیم.
تلفن: 09301904690