如何在Java数组类的工作? [英] How does array class work in Java?

查看:96
本文介绍了如何在Java数组类的工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Java中,数组是一类和扩展对象。我很想知道这个特殊的数组类。我没有在任何地方找到类定义。做的的getClass()。的getName()的给奇怪的结果。

In Java, array is a class and extends Object. I am curious to know about this special array class. I don't find the class definition anywhere. Doing a getClass().getName() gives strange result.

String[] array = new String[]{"one","two"};
System.out.println(array.getClass().getName()); // prints [Ljava.lang.String;

我想了解阵列引擎盖下是如何工作的。在JVM中的数组类高清硬codeD?

I want to understand how array works under the hood. Is the array class definition hardcoded in the JVM?

任何资源,书籍,在此环节会有所帮助。

Any resources, books, links on this will be helpful.

感谢您。

推荐答案

是的,基本上阵列东西VM知道亲密,就像原始类型。有特定字节code说明使用数组的工作 - 创建它们,索引放进去等

Yes, basically arrays are something the VM knows about intimately, like the primitive types. There are specific bytecode instructions to work with arrays - creating them, indexing into them etc.

至于资源,以了解更多 - 的 JVM规范可能是最好的起点。 7.9节有字节code使用数组的一些例子。

As for resources to find out more - the JVM specification is probably the best starting point. Section 7.9 has some examples of bytecode working with arrays.

这篇关于如何在Java数组类的工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆