阅前声明: http://blog.csdn.net/heimaoxiaozi/archive/2007/01/19/1487884.aspx
/****************** Exercise 2 ******************
* Put the methods ternary() and alternative()
* into a working program.
***********************************************/
public class E02_Ternary {
static int ternary(int i) {
return i < 10 ? i * 100 : i * 10;
}
static int alternative(int i) {
if (i < 10)
return i * 100;
else
return i * 10;
}
public static void main(String[] args) {
System.out.println(ternary(9));
System.out.println(ternary(11));
System.out.println(alternative(9));
System.out.println(alternative(11));
}
}
//+M java E02_Ternary