OnJava8-Examples/control/IfElse2.java

24 lines
441 B
Java
Raw Normal View History

2015-09-07 11:44:36 -06:00
// control/IfElse2.java
2015-11-14 16:18:05 -08:00
// <20>2016 MindView LLC: see Copyright.txt
2015-06-15 17:47:35 -07:00
public class IfElse2 {
static int test(int testval, int target) {
if(testval > target)
return +1;
else if(testval < target)
return -1;
else
return 0; // Match
}
public static void main(String[] args) {
2015-11-03 12:00:44 -08:00
System.out.println(test(10, 5));
System.out.println(test(5, 10));
System.out.println(test(5, 5));
2015-06-15 17:47:35 -07:00
}
2015-09-07 11:44:36 -06:00
}
/* Output:
2015-06-15 17:47:35 -07:00
1
-1
0
2015-09-07 11:44:36 -06:00
*/