学习c语言的时候,这些个东西起码还是很明确的,因为上课的时候,老师经常问,现在时间久了,见的语言多了,也就有点乱了,也没怎么在意过。
(武藏) 既然你诚心诚意的发问了,
(小次郎) 我们就大发慈悲的告诉你!
(武藏) 为了防止世界被破坏,
(小次郎) 为了守护世界的和平;
(武藏) 贯彻爱与真实的邪恶,
(小次郎) 可爱又迷人的反派角色~~
(武藏) 武藏!
(小次郎) 小次郎!
(合) 我们是穿梭在银河的火箭队!白洞,白色的明天在等着我们!!
(喵喵) 就是这样~喵~~~~
(阿伯怪) So~nansi~~~
先了解2个单词先:
1、bit 位:位是计算机中存储数据的最小单位,指二进制数中的一个位数,其值为“0”或“1”。
2、byte 字节:字节是计算机存储容量的基本单位,一个字节由8位二进制数组成。在计算机内部,一个字节可以表示一个数据,也可以表示一个英文字母,两个字节可以表示一个汉字。
1B=8bit
Java基本数据类型
int
32bit
short
16bit
long
64bit
byte
8bit
char
16bit
float
32bit
double
64bit
boolean
1bit
(boolean 的备注+翻译)
This data type represents one bit of information, but its "size" isn't something that's precisely defined.(ref)
这种数据类型代表一个比特的信息,但它的“大小”没有明确的定义。(参考)
测试代码如下:
class ClassForNameAndClassLoaderTest {
public static void main(String[] args) {
System.out.println("Integer: " + Integer.SIZE/8); // 4
System.out.println("Short: " + Short.SIZE/8); // 2
System.out.println("Long: " + Long.SIZE/8); // 8
System.out.println("Byte: " + Byte.SIZE/8); // 1
System.out.println("Character: " + Character.SIZE/8); // 2
System.out.println("Float: " + Float.SIZE/8); // 4
System.out.println("Double: " + Double.SIZE/8); // 8
System.out.println("Boolean: " + Boolean.toString(false));
}
}
以 Integer类为例如下:
/**
* The number of bits used to represent an {@code int} value in two's
* complement binary form.
*
* @since 1.5
*/
@Native public static final int SIZE = 32;
/**
* The number of bytes used to represent a {@code int} value in two's
* complement binary form.
*
* @since 1.8
*/
public static final int BYTES = SIZE / Byte.SIZE;//这个我加的注释 Byte.SIZE = 8;