首页 > 编程语言 > 详细

java基本数据类型练习

时间:2015-09-28 23:32:11      阅读:413      评论:0      收藏:0      [点我收藏+]
package javafirst;//包名

public class JavaFirstDay {
	//基本数据类型的练习
	public static void main(String[] args)
	{
		byte byteOne = 125;
		short shortOne = 12345;
		int intOne = 2345;
		long longOne = 123l;//默认为int
		float floatOne = 12.3f;//默认为double
		double doubleOne = 12.3;
		
		//char变量赋值的三种形式
		char charOne = ‘z‘;
		char charTwo = ‘中‘;
		char charThree = 99;
		
		boolean isBool = false;//布尔型
		
		final int finalInt = 12;//常量
		
		System.out.println("byteOne = "+byteOne);
		
		System.out.println("shortOne + 123 = "+ (shortOne + 123));//带括号转变为算术
		System.out.println("shortOne123 = " + shortOne + 123);//不带括号作为字符串连接
		
		System.out.print("intOne + 123 = ");
		System.out.println(intOne + 123);//无字符串连接为算术运算
		
		System.out.print("charThree = "+charThree+"\n换行符的练习");//转义字符
		
	}

}

  技术分享

java基本数据类型练习

原文:http://www.cnblogs.com/whytohow/p/4845133.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!