简体   繁体   English

java中的数组元素标识符?

[英]Are array elements identifiers in java?

Java documentation says that an identifier is "The name of an item in a program written in the Java(TM) programming language," but this doesn't specify if something of the form myList[0] counts as a name for the first element in myList. Java文档说标识符是“用Java(TM)编程语言编写的程序中项目的名称”,但这并未指定myList[0]形式的myList[0]是否为第一个元素的名称在myList中。 So, does myList[0] count as an identifier? 那么, myList[0]算作标识符?

myList[0] is not an identifier. myList[0]不是标识符。 It is an array access expression . 它是一个数组访问表达式 The identifier in this case is myList . 在这种情况下,标识符是myList

不,myList是数组的标识符,myList [0]指的是该数组的索引0内的元素,它引用了一种类型的值。

The ultimate place to check these definitions is the JLS (Java Language Specification) rather than a tutorial, which is naturally less formal. 检查这些定义的最终位置是JLS(Java语言规范),而不是教程,这自然不太正式。

According to said specification, an identifier does not include brackets. 根据所述说明书,标识符不包括括号。 Therefore myList[0] is not an identifier. 因此myList[0]不是标识符。

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

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