简体   繁体   English

数组是否与java.util包分开?

[英]Are arrays separate from the java.util package?

I am confused about a technicality. 我对技术性感到困惑。 I am completing a piece of work in Java, but there are restrictions on what we cannot use. 我正在用Java完成一项工作,但是对我们不能使用的内容有一些限制。

In particular, we not allowed to use the Arrays class from the java.util package. 特别是,我们不允许使用java.util包中的Arrays类。

I have used an array ( int[] example = new int[7] ), but as far as I understand, this is not included in the Arrays class - the Arrays class purely contains methods about dealing with arrays - such as copyOf and binarySearch . 我曾经使用过一个数组( int[] example = new int[7] ),但据我了解,它不包含在Arrays类中copyOf类仅包含有关处理数组的方法-例如copyOfbinarySearch

Am I breaking the assignment rules? 我是否违反了分配规则?

Thank you. 谢谢。

No you are not breaking the rules. 不,您没有违反规则。 Just don't use any Arrays api. 只是不要使用任何Arrays API。 Yes the arrays are separate from Arrays class. 是的,数组与Arrays类是分开的。 You can check this from a simple test Create an array and check the result of ' instanceof ' test. 您可以通过一个简单的测试来检查它。创建一个数组并检查' instanceof '测试的结果。 It will pass the test for Object class but fail for Arrays class Arrays class in the java.util package is just for providing most commonly used operations like binary, sorting etc. It is just a utility class. 它会通过Object类的测试,但不会通过Arrays类的测试。java.util包中的Arrays类仅用于提供最常用的操作,例如二进制,排序等。它只是一个实用程序类。 You can observe in the documentation that it has no constructor and all the methods are static . 您可以在文档中观察到它没有构造函数,并且所有方法都是静态的 I hope this helps. 我希望这有帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM