Skip to content

Instantly share code, notes, and snippets.

@siliconsenthil
Last active October 22, 2016 04:50
Show Gist options
  • Save siliconsenthil/fa951655d6b323d3522d441b13ca6f8c to your computer and use it in GitHub Desktop.
Save siliconsenthil/fa951655d6b323d3522d441b13ca6f8c to your computer and use it in GitHub Desktop.
If else
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