奇怪的组数length属性
Arrays are special objects in java, they have a simple attribute named length which is final.
There is no "class definition" of an array (you can't find it in any .class file), they're a part of the language itself.
10.7. Array Members
The members of an array type are all of the following:
- The
publicfinalfieldlength, which contains the number of components of the array.lengthmay be positive or zero.The
publicmethodclone, which overrides the method of the same name in classObjectand throws no checked exceptions. The return type of theclonemethod of an array typeT[]isT[].A clone of a multidimensional array is shallow, which is to say that it creates only a single new array. Subarrays are shared.
- All the members inherited from class
Object; the only method ofObjectthat is not inherited is itsclonemethod.
It's "special" basically, with its own bytecode instruction: arraylength. So this method:
public static void main(String[] args){
int x = args.length;
}
is compiled into bytecode like this:
public static void main(java.lang.String[]);
Code:
0: aload_0
1: arraylength
2: istore_1
3: return
通过javap更好的说明了数组的length属性,其实是一个单独的二进制指令:arraylength
奇怪的组数length属性的更多相关文章
- JavaScript 数组 length 属性获取数组长度或设置数组元素的数目
JavaScript 数组 length 属性 JavaScript 数组 length 属性可返回或设置或组中元素的数目,语法如下: array_object.length 利用 length 属性 ...
- JavaScript 组数去重demo
<!doctype html> <html> <head> <meta charset="utf-8"> <title> ...
- DOM中XMLDOMnodelist的length属性的表示是:(选择1项)
DOM中XMLDOMnodelist的length属性的表示是:(选择1项) A. 该对象中文本字符的长度 B. 该对象中元素节点的数量 C. 该对象中节点的数量 D. 该对象中文档对象的数量 解答: ...
- String 对象-->length 属性
1.定义和用法 length 属性返回字符串的长度(字符数). 语法: string.length 注意:根据各国字符长度计算长度 举例: var str = 'abner pan' console. ...
- length属性,length()方法和size()的方法的区别
一.java 1.length属性是针对Java中的数组来说的,要求数组的长度可以用其length属性: 2.length()方法是针对字符串来说的,要求一个字符串的长度就要用到它的length()方 ...
- jQuery Length属性
Length属性 属性用于返回当前jQuery对象的元素个数. 语法 jQueryObject.length 返回值 Number类型 返回该jQuery对象封装的DOM元素的个数. 实例说明 代码 ...
- mysql 怎么查询出,分组后的总条数。。。也就是有多少组数。。。。怎么写
SELECT COUNT(*) AS 多少组数FROM( SELECT id FROM 表 GROUP BY id) subQuery;Mysql,有一个表含有以下字段,uid 发帖人id,title ...
- Javascript中length属性的总结
Javascript中length属性的总结 一.StringObject中的length length属性是返回字符串的字符数目. 例如: // 普通字符串 var str = " ...
- 数组length属性的一些特性
~~·数组的length属性是可读写的 var colors = ["blue","red","green"];colors.length ...
随机推荐
- MAC下搭建个人博客
安装homebrew ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/inst ...
- c++ cmath头文件
一.前言 c++的一个头文件. 二.常用方法 1. ceil() 定义: c++11 double ceil (double x); float ceil (float x); long double ...
- Ajax的实现及使用-原生对象
正文 学习JavaScript就不得不提到Ajax,从2005年开始,Ajax技术就开始席卷整个Web世界.作为一个前端来说,大部分时间中都是使用的库中封装好的ajax模块(jQuery),即使已使用 ...
- tensorflow 文件队列
使用文件队列,防止爆内存 # # 通过队列打开图片文件 file_queue = tf.train.string_input_producer(paths) img_reader = tf.Whole ...
- 面向对象的封装与隐藏 this
当我们创建一个对象的时候,我们可以通过‘对象.属性’的方式,对对象的属性进行赋值. 这里赋值操作要受到属性的数据类型和存储范围的制约,但是除此之外,没有其他制约条件. 但是实际问题中我们需要给这个属性 ...
- Arch Linux 更新源(以清华 arch 源为例)
Arch Linux 编辑/etc/pacman.d/mirrorlist,在文件最顶端添加: Server = https://mirrors.tuna.tsinghua.edu.cn/archl ...
- HTTP请求行、请求头、请求体详解(转)
转自 https://blog.csdn.net/u010256388/article/details/68491509/ HTTP请求报文解剖 HTTP请求报文由3部分组成(请求行+请求头+ ...
- 第七章 鼠标(CHECKER2)
CHECKER2程序包含一个键盘接口,内容与CHECKER1完全相同.利用←.→.↑.↓四个方向键可以在25个矩形之间移动鼠标指针.Home键把鼠标指针移动到左上角的矩形:End键使鼠标指针落到右下角 ...
- .NET Core tasks.json 简介
1.执行命令:dotnet> dotnet new console -o myApp 2.tasks.json文件配置: { "version": "2.0.0&q ...
- php报错 【 Call to undefined function imagecreatetruecolor()】
刚才在写验证码的时候,发现报错,然后排查分析了一下,原来是所用的php版本(PHP/5.3.13)没有开启此扩展功能. 进入php.ini 找到extension=php_gd2.dll ,将其前面的 ...