Skip to content

Instantly share code, notes, and snippets.

@soudmaijer
Created April 8, 2021 09:30
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 soudmaijer/ed3e73a61a7b20c6fc9f46614b21cf03 to your computer and use it in GitHub Desktop.
Save soudmaijer/ed3e73a61a7b20c6fc9f46614b21cf03 to your computer and use it in GitHub Desktop.
public class IfWhen {
public static boolean yesNoToBoolean(String s) {
if ("yes".equals(s)) return true;
else if ("no".equals(s)) return false;
else throw new RuntimeException("Unsupported value: " + s);
}
public static void main(String[] args) {
System.out.println(yesNoToBoolean("yes"));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment