Skip to content

Instantly share code, notes, and snippets.

@BenMcH
Created August 1, 2013 04:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BenMcH/6128376 to your computer and use it in GitHub Desktop.
Save BenMcH/6128376 to your computer and use it in GitHub Desktop.
String one = "One";
if(userInput == one)
{
return true;
}
return false;
Assume userInput is a string input by the user (That is "One"). This will return false, while
if(userInput.equals(one))
{
return true;
}
return false;
This will return true.
You can also do
if(userInput.equalsIgnoreCase(one))
{
return true;
}
return false;
will return true ignoring case.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment