Skip to content

Instantly share code, notes, and snippets.

@ghtali
Last active December 27, 2017 01:08
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 ghtali/16ad40e9b106aaa283699e8f6b31f2a8 to your computer and use it in GitHub Desktop.
Save ghtali/16ad40e9b106aaa283699e8f6b31f2a8 to your computer and use it in GitHub Desktop.
Finding minimum number by using Method Calling in Java
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