java中的八種基本數(shù)據(jù)類型是:1、byte;2、short;3、int;4、long;5、float;6、double;7、char;8、boolean。
本文操作環(huán)境:windows10系統(tǒng)、java 1.8、thinkpad t480電腦。
(學(xué)習(xí)視頻分享:java視頻教程)
詳細(xì)介紹:
Java中的8種基本數(shù)據(jù)類型,其名稱、位數(shù)、默認(rèn)值、取值范圍及示例如下表所示:
舉例驗證:
package com.ce.test; class Test { static byte b; static short s; static int i; static long l; static float f; static double d; static char c; static boolean bo; public static void main(String[] args) { System.out.println("byte的大小:"+Byte.SIZE +";默認(rèn)值:"+b +";數(shù)據(jù)范圍:"+Byte.MIN_VALUE+" - "+Byte.MAX_VALUE); System.out.println("short的大?。?quot;+Short.SIZE +";默認(rèn)值:"+s +";數(shù)據(jù)范圍:"+Short.MIN_VALUE+" - "+Short.MAX_VALUE); System.out.println("int的大?。?quot;+Integer.SIZE +";默認(rèn)值:"+i +";數(shù)據(jù)范圍:"+Integer.MIN_VALUE+" - "+Integer.MAX_VALUE); System.out.println("long的大?。?quot;+Long.SIZE +";默認(rèn)值:"+l +";數(shù)據(jù)范圍:"+Long.MIN_VALUE+" - "+Long.MAX_VALUE); System.out.println("float的大?。?quot;+Float.SIZE +";默認(rèn)值:"+f +";數(shù)據(jù)范圍:"+Float.MIN_VALUE+" - "+Float.MAX_VALUE); System.out.println("double的大?。?quot;+Double.SIZE +";默認(rèn)值:"+d +";數(shù)據(jù)范圍:"+Double.MIN_VALUE+" - "+Double.MAX_VALUE); System.out.println("char的大?。?quot;+Character.SIZE +";默認(rèn)值:"+c +";數(shù)據(jù)范圍:"+Character.MIN_VALUE+" - "+Character.MAX_VALUE); System.out.println("boolean的大?。?quot;+Byte.SIZE +";默認(rèn)值:"+bo +";數(shù)據(jù)范圍:"+Byte.MIN_VALUE+" - "+Byte.MAX_VALUE); } }
在控制臺輸出結(jié)果如下圖所示: