将 Arrays.copyOfRange 从 Java 6 移植到 Java 5
我有一些源代码需要在 Java 5 下运行。不幸的是,该代码使用 Arrays.copyOfRange 函数,仅在 Java 6 中引入。仅使用 Java 5 API 实现相同实用程序的最有效方法是什么?
I have some source code that I need to make runnable under Java 5. Unfortunetly that code uses Arrays.copyOfRange function which was only introduced in Java 6. What would be the most effective way to implement same utility using only Java 5 API?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
以下是来自 OpenJDK 的代码,供感兴趣的人参考:
Here goes the code from OpenJDK for those who are intrested:
查看 OpenJDK 6 页面 - 它是开源 Java。您可以自行下载并阅读源代码,了解其实现方式,并手动将功能添加到应用程序中。
Check out the OpenJDK 6 page - it's open source Java. You can download and read the source code yourself, find out how it's implemented, and add the functionality to the app manually.
最快的方法是使用 System.arraycopy。顺便说一句,这就是 Arrays 类所做的事情。
The fastest way would be to use
System.arraycopy
. It's what's done by the Arrays class, BTW.