How to check spaces in Java
•
Java
String selectedVal = "";
String selectedVal = ""; for (SelectItem item : filterItems) { selectedVal = item.getValue().toString(); break; }
I'm getting selectedval = "" how to check this blank area in Java
I try to use if (! Selectedval. Equals ("") and if (! Selectedval. Isempty()) but the condition becomes true How do I check multiple spaces?
Solution
You can trim () strings before checking with isempty()
boolean isEmpty = myString.trim().isEmpty();
Beware of isempty (), which is only available after Java se 6
resources:
> javadoc – String. trim() > javadoc – String. isEmpty()
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码