String selectedVal = "";
for (SelectItem item : filterItems) {
selectedVal = item.getValue().toString();
break;
}
I am getting selectedVal=" " how to check this empty space in java.
I tried with if(!selectedVal.equals("") and if(!selectedVal.isEmpty()) but condition getting true.How to check more than one empty space ?
You can trim()
your string before checking with isEmpty()
boolean isEmpty = myString.trim().isEmpty();
Beware of isEmpty()
, it's only available since Java SE 6
Resources :
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With