How to check if my string is equal to null?
- by Roman
I want to perform some action ONLY IF my string has a meaningful value. So, I tried this.
if (!myString.eqauls("")) {
doSomething
}
and this
if (!myString.eqauls(null)) {
doSomething
}
and this
if ( (!myString.eqauls("")) && (!myString.eqauls(null))) {
doSomething
}
and this
if ( (!myString.eqauls("")) && (myString!=null)) {
doSomething
}
and this
if ( myString.length()>0) {
doSomething
}
And in all cases my program doSomething in spite on the fact that my string IS EMPTY. It equals to null. So, what is wrong with that?