对于此示例Java类:
package foo;
public class TestInterop
{ public String test(int i)
{ return "Test(int)"; }
public String test(Object i)
{ return "Test(Object)"; }
}
Run Code Online (Sandbox Code Playgroud)
当我启动Clojure并尝试调用test(int)方法时,将调用test(Object)方法,因为Clojure会自动将整数写入java.lang.Integer对象.
如何强制Clojure调用test(int)方法?
user=> (.test (new foo.TestInterop) 10)
"Test(Object)"
Run Code Online (Sandbox Code Playgroud)
我想调用类似于Component.add(Component comp, int index)AWT的方法,而是继续调用add(Component comp, Object constraints),因此工具栏上的按钮总是以错误的顺序出现.