?? extendedoperation.java
字號:
// Subclass of extensible, serializable typesafe enum - Page 112
import java.io.*;
abstract class ExtendedOperation extends Operation {
ExtendedOperation(String name) { super(name); }
public static Operation LOG = new ExtendedOperation("log") {
protected double eval(double x, double y) {
return Math.log(y) / Math.log(x);
}
};
public static Operation EXP = new ExtendedOperation("exp") {
protected double eval(double x, double y) {
return Math.pow(x, y);
}
};
// The 4 declarations below are necessary for serialization
private static int nextOrdinal = 0;
private final int ordinal = nextOrdinal++;
private static final Operation[] VALUES = { LOG, EXP };
Object readResolve() throws ObjectStreamException {
return VALUES[ordinal]; // Canonicalize
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -