mathtool.java
来自「java servlet编程源码」· Java 代码 · 共 44 行
JAVA
44 行
import org.webmacro.*;
public class MathTool implements ContextTool {
/**
* A new tool object will be instantiated per-request by calling
* this method. A ContextTool is effectively a factory used to
* create objects for use in templates. Some tools may simply return
* themselves from this method; others may instantiate new objects
* to hold the per-request state.
*/
public Object init(Context c) {
return this;
}
public static int add(int x, int y) {
return x + y;
}
public static int subtract(int x, int y) {
return x - y;
}
public static int multiply(int x, int y) {
return x * y;
}
public static int divide(int x, int y) {
return x / y;
}
public static int mod(int x, int y) {
return x % y;
}
public static boolean lessThan(int x, int y) {
return (x < y);
}
public static boolean greaterThan(int x, int y) {
return (x > y);
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?