java 知识



  1、Identifiers:标识符

   ①Names of class,method and variable:用于类名、方法名、变量名

  ②Begin with character,"_" or "$":标识符不能以数字开头

  ③Case sensitive:大小写敏感(区分大小写)

  ④No length limitation:长度无限制

  ⑤标识符不能是Java关键字,汉字也可以做标识符,但是不建议使用(使用汉字涉及到编码问题,跨平台时回出现问题)。

  ⑥StringJava的一个类,类名是标识符,所以String可以做标识符。

  ⑦There is no sizeof operator.Java中没有sizeof运算符,所以sizeof可以作为标识符

  ⑧关键字、保留字(const、goto、true、false、null)不能用作标识符。

复制代码
 1 public class Identifiers {
 2     public static void main(String[] args) {
 3         String $abc="abc1";
 4         String _abc="abc2";
 5         //编译错误,标识符不能以数字开头
 6         //String 8abc="abc3";  
 7         String 中国="China";
 8         String String="wanghao";
 9         int Integer=22;
10         //Java中没有sizeof运算符,所以sizeof可以作为标识符
11         String sizeof="sizeof";
12         System.out.println(String);//wanghao
13         System.out.println(Integer);//22
14     }
15 }
复制代码

 

  2、Keywords关键字



The goto and const keyword are not used in the Java programming.

  const 保留关键字(留儿不用)。const是从C++继承而来的,但是Java并不使用const这个关键字,由于JVM是由C++编写的,因此,虽然Java并不使用const这个关键字,但却要保留下来。和const一样goto也是保留关键字!

  关键字全部用小写表示(53个)

  Strictly speaking,the literals true,false,and null are not keywords but literals;however,the distinction is academic.

true,false,and null是保留字但不是关键字,只是3个值,不能用来做关键字



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值