java入门知识点1:变量与常量

1.基本数据类型
基本数据类型
2.java标识符:由数字、下划线、字母组成,但是不能以数字开头

3.自动类型转换与强制类型转换的区别

自动类型转换:精度低的转化为精度高的

public static void main(String[] args) {
		
	double avg1=78.5;
		
	int rise=5;
		
	double avg2=avg1+rise;
		
	System.out.println("考试平均分:"+avg1);
		
	System.out.println("调整后的平均分:"+avg2);
	
}

强制类型转换:精度高的转化为精度低的

public static void main(String[] args) {
		
	double heightAvg1=176.2;
		
	int heightAvg2=(int)heightAvg1;
		
	System.out.println(heightAvg1);
		
	System.out.println(heightAvg2);
	
}

猜你喜欢

转载自blog.csdn.net/qq_43501462/article/details/98482267
今日推荐