#千峰JAVA逆战班,3月18日#

在千锋“逆战”学习第 3 天;
奋斗没有终点,任何时候都是一个起点;
今天学习的课程有4类8种基本数据类型,String引用数据类型,数据类型的自动以及强制转换;
中国加油!武汉加油!千锋加油!
我自己加油!

public class TestDateType{
	public static void main(String[] args){
		
		byte b = -128;
		short s = 32767;
		int i = 210000000;
		long l1=100;
		long l2 = 3000000000000L;
		System.out.println(b);
		System.out.println(s);
		System.out.println(i);
		System.out.println(l1);
		System.out.println(l2);
		System.out.println(Long.MAX_VALUE);
		//此为java内一种类的功能:long整型的最大取值
		System.out.println("++++++++++++");
		
		float f = 1.23F;
		double d1 = 200;
		//此隐含了int转double型的自动转换
		double d2 = 2E2;
		double d3 = 200.0;
		//d1,d2,d3为3个不同的表达方式。
		System.out.println(f);
		System.out.println(d1);
		System.out.println(d2);
		System.out.println(d3);
		System.out.println("+++++++++++++");
		
		boolean b1 = true;
		boolean b2 = 3+2<4;
		System.out.println(b1);
		System.out.println(b1);
		System.out.println("+++++++++++++");
		
		char c1 = '中';
		char c2 = 22269;
		char c3 = '\u0041';
		System.out.println(c1);
		System.out.println(c2);
		System.out.println(c3);
		System.out.println("+++++++++++++");
		
		String str = "武汉    加油";
		System.out.println(str);
		char c4 = '\'';
		System.out.println("\'\\\"\tfright");
		System.out.println(c4);
		System.out.println("+++++++++++++");
		
		
		byte bb1 = 2;
		int ii1 = bb1;
		System.out.println(ii1);
		
		int ii2 = 128;
		byte bb2 = (byte)ii2;
		System.out.println(bb2);
		/*
		整型:2进制
		byte--->short:自动转换
		byte:8位
			0000 0001
		short:16位
			0000 0000 1000 0000


		short-->byte:强制转换,因为数据存在不安全性
		0000 0000 1000 0000
		1000 0000
		且整数都是以补码存储
		*/
		
		double dd1 = 1.23;
		float ff1 = (float)dd1;
		System.out.println(ff1);
		
		float ff2 = 4.56F;
		long ll1 = (long)ff2;
		System.out.println(ll1);
		
		char cc1 = 65;
		int ii3 = cc1;
		System.out.println(113);
		
		short ss1 = -65;
		char cc2 = (char)ss1;
		System.out.println(cc2);
		//(-65-->?)语法虽然正确,但是计算机却找不到-65的编码对应
		
	}
	
}
发布了11 篇原创文章 · 获赞 3 · 访问量 397

猜你喜欢

转载自blog.csdn.net/yuxinganggame/article/details/104955284
今日推荐