Last active
October 22, 2016 04:50
-
-
Save siliconsenthil/fa951655d6b323d3522d441b13ca6f8c to your computer and use it in GitHub Desktop.
If else
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 boolean decide(int s){ | |
boolean result = false; | |
if (s == 1){ | |
result = true; | |
}else{ | |
result = false; | |
} | |
return result; | |
} | |
public String tellme(int i){ | |
String result = null; | |
if(i == 1){ | |
result = "This is one"; | |
} | |
if(i == 2){ | |
result = "This is two"; | |
} | |
if(i == 3){ | |
result = "This is three"; | |
}else{ | |
result = "This is something else"; | |
} | |
return result; | |
} | |
private static String getSoundIfElseWay(String animal) { | |
if (animal.equalsIgnoreCase("Dog")) | |
return "Bark"; | |
else if (animal.equalsIgnoreCase("Cat")) | |
return "Mew"; | |
else if (animal.equalsIgnoreCase("Lion")) | |
return "Roar"; | |
return ""; | |
} | |
//http://siliconsenthil.in/blog/2011/04/15/if-else-or-switch-case-to-polymorphism/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment