Names and Identifiers

 

JLS:https://docs.oracle.com/javase/specs/jls/se7/html/jls-6.html#jls-6.2

 

Not all identifiers in a program are a part of a name. Identifiers are also used in the following situations:

(1)In declarations (§6.1), where an identifier may occur to specify the name by which the declared entity will be known.

(2)As labels in labeled statements (§14.7) and in break andcontinue statements (§14.15§14.16) that refer to statement labels.

(3)In field access expressions (§15.11), where an identifier occurs after a "." token to indicate a member of an object that is the value of an expression or the keyword super that appears before the "." token

 

  

  

 

(4)In some method invocation expressions (§15.12), where an identifier may occur after a "." token and before a "(" token to indicate a method to be invoked for an object that is the value of an expression or the keyword super that appears before the "." token

 

(5)In qualified class instance creation expressions (§15.9), where an identifier occurs immediately to the right of the leftmost new token to indicate a type that must be a member of the compile-time type of the primary expression preceding the "." preceding the leftmost new token.

 

 

 

 

 

1、Primary Expressions 

 

Primary:
    PrimaryNoNewArray
    ArrayCreationExpression

PrimaryNoNewArray:
    Literal
    Type . class
    void . class
    this
    ClassName . this
    ( Expression )
    ClassInstanceCreationExpression
    FieldAccess
    MethodInvocation
    ArrayAccess

 

 

 

15.8.1. Lexical Literals 

 

Literal:
    IntegerLiteral
    FloatingPointLiteral
    BooleanLiteral
    CharacterLiteral
    StringLiteral
    NullLiteral

 

 

 

15.8.2. Class Literals

 

class TC<T>{
	public void test(){
		//Object t = T.class; // error
		Class<ArrayList> l = ArrayList.class;  
		// Class<ArrayList> l = ArrayList<String>.class; // error 
		Class<Integer> o = int.class;
		Class<Void> v = void.class;
		
	}
}

 

 

 

15.8.3. this

 

 

 

15.8.4. Qualified this 

 

 

 

15.8.5. Parenthesized Expressions

 

 

 

2、Field Access Expressions

 

FieldAccess: 
    Primary . Identifier
    super . Identifier
    ClassName . super . Identifier

 

  

 

 

 

3、Method Invocation Expressions

 

MethodInvocation:
    MethodName ( ArgumentListopt )
    Primary . NonWildTypeArgumentsopt Identifier ( ArgumentListopt )
    super . NonWildTypeArgumentsopt Identifier ( ArgumentListopt )
    ClassName . super . NonWildTypeArgumentsopt Identifier ( ArgumentListopt )
    TypeName . NonWildTypeArguments Identifier ( ArgumentListopt )

 

3.1、ArgumentList

 

ArgumentList:
    Expression
    ArgumentList , Expression

 

  

 

 

 

4、Class Instance Creation Expressions 

 

ClassInstanceCreationExpression:
    new TypeArgumentsopt TypeDeclSpecifier TypeArgumentsOrDiamondopt
                          ( ArgumentListopt ) ClassBodyopt
    Primary . new TypeArgumentsopt Identifier TypeArgumentsOrDiamondopt
                          ( ArgumentListopt ) ClassBodyopt

TypeArgumentsOrDiamond:
    TypeArguments
    <> 

ArgumentList:
    Expression
    ArgumentList , Expression

 

 

 

 

 

 

 

 

 

 

 

 

 

  

 

转载于:https://www.cnblogs.com/extjs4/p/9282473.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值