Sample Data

Difference between isEmpty & isBlank methods from String class:

Note : isBlank is newly added method from java 11.


isEmpty : isEmpty will not consider the white space as empty string .

Example :
String code1 = ” “;
boolean res = code1.isEmpty( ); //output : false

isBlank : isBlank will consider the white space as empty string.

Example :
String code2 = ” “;
boolean res = code2.isBlank( ); //output : true