Last active
December 27, 2017 01:08
-
-
Save ghtali/16ad40e9b106aaa283699e8f6b31f2a8 to your computer and use it in GitHub Desktop.
Finding minimum number by using Method Calling in Java
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 Example { | |
public static void main(String[] args) { | |
// TODO Auto-generated method stub | |
int a = 9; | |
int b = 6; | |
int c = minFunction(a,b); | |
System.out.println("Minimum value = " + c); | |
} | |
private static int minFunction(int n1, int n2) { | |
// TODO Auto-generated method stub | |
int min = 0; | |
if (n1 < n2) { | |
min = n1; | |
}else if(n1 == n2) { | |
System.out.println("a & b are equal so there's no minimum"); | |
}else { | |
min = n2; | |
} | |
return min; | |
} | |
} | |
//A personal training, source: https://www.tutorialspoint.com |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment