package com.java.datatype;
/**
* Java 数据类型总结: 基本类型和引用类型
* Java有八种基本类型
* 4种整型 int(4)(2^31~2^31-1),short(2),long(8),byte(1) 计算方法和int一样
* 2种浮点型 float(4)(-3.403E38~3.403E38) double(8)(-1.798E308~1.798E308)
* char(2)
* boolean(1)
* 基本数据类型的转换(容量小的自动转换成容量大的):
* byte -> short,char -> int -> long -> float -> double
*
* double: 表示溢出和出错的三个特殊情况
* 正无穷大:正整数/0
* 负无穷大:
* NAN: 0/0 或者 负数的平方根
*
* 检测NAN:
* Double.isNaN(x) 而不是 x==Double.NaN
* 引用类型:类,接口和数组
* @author 物业小学徒
*
*/
public class DataType {
public DataType() {
// TODO Auto-generated constructor stub
}
public static void main(String[] args) {
int int1 = 10;
short short1 = (short)100;
double d1 = 12.00d;
float f1 = 12.313f;
long l1 = 1221l;
byte b1 = (byte)1;
char c1 = '中';
boolean bool = true;
System.out.println(int1);
System.out.println(short1);
System.out.println(d1);
System.out.println(f1);
System.out.println(l1);
System.out.println(b1);
System.out.println(c1);
System.out.println(bool);
System.out.println(0.0/0.0);
System.out.println(-0.0/0.0);
System.out.println(0/0);
}
}
2. Java数据类型
猜你喜欢
转载自blog.csdn.net/qq_34087797/article/details/90177449
今日推荐
周排行