【在线等】《java核心技术卷1》中的代理的一个小问题

黑色价值 黑色价值 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
public class ProxyTest
{
public static void main(String[] args)
{
Object[] elements = new Object[1000];

// fill elements with proxies for the integers 1 ... 1000
for (int i = 0; i < elements.length; i++)
{
Integer value = i + 1;
InvocationHandler handler = new TraceHandler(value);
Object proxy = Proxy.newProxyInstance(null, new Class[] { Comparable.class } , handler);
elements[i] = proxy;
}

// construct a random integer
Integer key = new Random().nextInt(elements.length) + 1;

// search for the key
int result = Arrays.binarySearch(elements, key);

// print match if found
if (result >= 0) System.out.println(elements[result]);
}
}

这是代码的一部分,代码不重要,我只想问问其中 Object proxy = Proxy.newProxyInstance(null, new Class[] { Comparable.class } , handler);这句代码怎么理解,尤其是Comparable.class这代表什么,这样写是什么意思~~~
...全文
评论 3
收藏 已收藏
分享
返回顶部
黑色价值
Java SE 62,620 成员 307,251 内容