Skip to content

Instantly share code, notes, and snippets.

@jnraine
Created February 7, 2012 22:04
Show Gist options
  • Save jnraine/1762393 to your computer and use it in GitHub Desktop.
Save jnraine/1762393 to your computer and use it in GitHub Desktop.
Using strings as booleans in Java
/* The ugly way */
String isSomething = "true"
if ( "true".equals(isSomething) ) {
/* It takes me a couple seconds to figure out why I'm here */
}
/* The easy-to-read way */
String isSomething = true
if ( isSomething ) {
/* I know exactly why I'm here */
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment