Difference between isEmpty() and isBlank() Method in java 11

后端 未结 3 1859
悲&欢浪女
悲&欢浪女 2020-12-10 01:50

Java 11 has added A new instance method isBlank() to java.lang.String class.

What\'s the basic difference between the exi

3条回答
  •  独厮守ぢ
    2020-12-10 02:45

    The difference is as below :-

    isBlank() returns true for the string having only white space characters whereas isEmpty() will return false for such strings.

    ("\n\r  ").isBlank();  //returns true
    ("\n\r  ").isEmpty();  //returns false
    

    For detailed explanation with Code Example visit : isBlank() vs isEmpty() in String class Java

提交回复
热议问题