Nat*_*han 1 java methods class
在如下的程序中:
package testing;
import MarcoLib.Mouse;
import MarcoLib.Timings;
public class Testing {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
Mouse.pressMouse(1);
}
}
Run Code Online (Sandbox Code Playgroud)
有没有办法在Mouse.pressMouse()没有使用鼠标前缀的情况下打电话?
您可以导入静态方法:
import static com.company.Mouse.pressMouse;
public static void main(String[] args) {
pressMouse(1); // No need to prefix with "Mouse."
}
Run Code Online (Sandbox Code Playgroud)