JAVA—基础注释、常量及标识符用法

/**

  • 用来测试注释的用法(包含:多行注释、单行注释、文档注释)
  • @author 老窦

*/
public class TestComment {

/**
 * 这是程序入口
 * @param args 参数
 */
public static void main(String[] args/*我是多行注释!*/){
	System.out.println("测试注释 ");  //这是打印语句...
}

/*
我是多行注释!
我是多行注释!
*/

}

/**

  • 测试常量
  • @author 老窦

*/
public class TestConstant {

public static void main(String[] args) {
	int age = 18;
	final  String NAME = "douqiushi"; //尽量用大写
	
	final double PI = 3.14;
	//PI = 3.15;//编译错误,不能再被赋值!
	double r = 4;
	double area = PI*r*r;
	double circle = 2*PI*r;
	System.out.println("area = " +  area);
	System.out.println("circle =" + circle);
			
}

}

/**

  • 测试标识符的用法
  • @author 老窦

*/
public class TestIdentifer {

public static void main(String[] args) {
	int a123 = 1;
	//int 123abc = 2;  	//数字不能开头
	int $a = 3;
	int _abc=4;
	//int #abc = 5;
	
	int 年龄 = 18; 		//可以使用汉字,一般不建议用
	//int class = 2;	//关键字不能作为标识符
}

}

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值