Is it possible to simply check a java String argument is present and return a boolean true or return false if the argument is of a Null value?

boolean isNull = stringArg == null;

Thank you for you response would the code below be an acceptable way of incorporating this, I'm fairly new to java and tend to over lengthen my code. Thank you again


[
public boolean myWord(String word)
{
boolean isNull = word== null;
if (isNull = false)
{
return false;
}
else
{
return true;
}
}
]

Your logic looks OK (except you need == to test for equality, not just =), but pretty lengthy and redundant - how about:

public boolean myWordIsNull(String word) {
   return word == null;
}

Your logic looks OK (except you need == to test for equality, not just =), but pretty lengthy and redundant - how about:

public boolean myWordIsNull(String word) {
   return word == null;
}

end quote.

If I used this am I right it would return true if Null was found
if I wanted false if Null was found but true if a String was found would this adaption be okay. - My lack of experiance shows in the comparisons of the texts - thank you

public boolean myWordIsNull(String word) {
   return word != null;
}

Edited 3 Years Ago by mike_2000_17: Fixed formatting

This question has already been answered. Start a new discussion instead.