public class DataType1
{
public static void main(String args[])
{
byte a = 127; //定义一个byte类型变量a,赋初值为127。
int b = 100; //定义一个int类型变量b,赋初值为100。
short c = 32767; //定义一个short类型变量c,赋初值为32767。
long d = 10000000; //定义一个long类型变量d,赋初值为10000000。
float e = 5.0f; //定义一个float类型变量e,赋初值为5.0。
double f = 5.0; //定义一个都变了类型变量f,赋初值为5.0。
System.out.println("a = " + a); //输入a的值。
System.out.println("b = " + b);
System.out.println("c = " + c);
System.out.println("d = " + d);
System.out.println("e = " + e);
System.out.println("f = " + f);
a++;
System.out.println("a+1 = " + a);
System.out.println("a+2 = " + (a+1));
c++;
System.out.println("c+1 = " + c);
System.out.println("c+21 = " + (c+20));
}
}
/*
运行结果:
a = 127
b = 100
c = 32767
d = 10000000
e = 5.0
f = 5.0
a+1 = -128
a+2 = -127
c+1 = -32768
c+21 = -32748
*/
DataType1
最新推荐文章于 2020-04-13 20:17:06 发布