Created
April 8, 2021 09:30
-
-
Save soudmaijer/ed3e73a61a7b20c6fc9f46614b21cf03 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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