标识符是脚本中变量,函数和标签的名称。
Nashorn中的标识符是一个Unicode字符序列,具有以下规则:
以下是有效标识符的示例:
Id
_id
e$Id
num1
以下是无效标识符:
4num //Cannot start with a digit
emp id //Cannot contain spaces
emp+id //Cannot contains the + sign
break //break is a reserved word and cannot be used as an identifier
Nashorn中保留字的列表用作关键字
break do instanceof typeof
case else new var
catch finally return void
continue for switch while
debugger function this with
default if throw
delete in try
Nashorn未来保留词的列表
class enum extends super
const export import
Nashorn未来保留字的列表在严格模式
implements let private public
yield interface package protected
static
Nashorn支持两种类型的注释:
在Nashorn中编写注释的语法与Java的语法相同。
以下是注释的示例:
// A single-line comment
var Id;
/*
A multi-line comment
*/
var et;
var d;
© 著作权归作者所有