package myMain;
public enum Menum {
ADD {
public String calc(double a, double b) {
return String.valueOf(a + b);
}
},
SUB {
@Override
public String calc(double a, double b) {
return String.valueOf(a - b);
}
},
MUL {
@Override
public String calc(double a, double b) {
return String.valueOf(a * b);
}
},
DIV {
@Override
public String calc(double a, double b) {
return String.valueOf(a / b + a % b);
}
};
public abstract String calc(double a, double b);
public static void main(String[] args) {
mCalc(Menum.MUL, 4, 2);
}
public static void mCalc(Menum m, double a, double b) {
String result = m.calc(a, b);
System.out.println(result);
}
}
Java
Javaagent简单应用
前置资料 windowns 10 JDK 1.8.0 了解Jar命令怎 阅读更多…