一、关键字

abstract

assert

boolean

break

byte

case

catch

char

class

const

continue

default

do

double

else

enum

extends

final

finally

float

for

goto

If

implements

import

instanceof

int

interface

long

native

new

package

private

protected

public

return

strictfp

short

static

super

switch

synchronized

this

throw

throws

transient

try

void

volatile

while

  • Java所有的组成部分都需要名字。类名、变量名以及方法名都被称为标识符

二、标识符注意点

  • 所有的标识符都应该以字母(A-Z或a-z),美元符($)、或者下划线(_)开始
  • 首字母之后可以使用字母(A-Z或a-z),美元符($)、或者下划线(_)或数字的任何字符组合
  • 不能使用关键字作为变量名或方法名
  • 标识符是大小写敏感的
  • 合法标识符举例:age、$salary、_value、__1_value
  • 非法标识符举例:123abc、-salary、#abc
public static void main(String[] args) {
        String 王者荣耀 = "最强王者";
        System.out.println("Hello,World!");
    }
  • 可以使用中文命名,但是一般不建议这样去使用,也不建议使用拼音,很low


示例:

public class Demo01 {
    public static void main(String[] args) {


        String 王者荣耀 = "百星王者";
        System.out.println(王者荣耀);


        String Ahello = "qinfen";
        String hello = "qinfen";
        String $Ahello = "qinfen";
        String _Ahello = "qinfen";
    }
}