Skip to main content

java 基本类型

· One min read

背景

了解java的基本类型,基本类型的大小和取值范围

platform:amd64

源码分析

在c++ standard 里面

类型是否有符号最小范围字节数type
charimplement defined [Type char is a distinct type that has an implementation-defined choice of “signed char” or “unsigned char” as its underlying type]--
signed charsigned--signed type
short intsigned--signed type
intsigned--signed type
long intsigned--signed type
long long intsigned--signed type

在linux 64位下面

java基本类型c/c++宏
jintint
jlonglong
jbytesigned char
jbooleanunsigned char
jcharunsigned short
jfloatfloat
jdoubledouble
jsizejint 也就是int
// jdk/src/java.base/unix/native/include/jni_md.h
typedef int jint;
#ifdef _LP64
typedef long jlong;
#else
typedef long long jlong;
#endif

typedef signed char jbyte;
// jdk/src/java.base/share/native/include/jni.h
#ifndef JNI_TYPES_ALREADY_DEFINED_IN_JNI_MD_H

typedef unsigned char jboolean;
typedef unsigned short jchar;
typedef short jshort;
typedef float jfloat;
typedef double jdouble;

typedef jint jsize;

相关阅读