Primitive Types:
1) byte:
size: 8-Bit = 1-Byte
range: -128~+127
usage:
1> The byte data type can be useful for saving memory in large arrays, where memory saving actually matters.
2> They can also be used in place of int where their limits help to clearify your code. The fact that a variable's range is limited can serve as a form of documentation.
2) short:
size: 16-Bit = 2-Byte
range: -32768~+32767
usage:
1> You can use short to save memory in large arrays, in situation memory where memory savings acutally matters.
3) int:
size: 32-Bit = 4-Byte
range: -(2^31)~+(2^31-1)
4) long:
size: 64-Bit = 8-Byte
range: -(2^63) ~ +(2^63-1)
5) float:
size: single-precision 32-Bit IEEE 754 floating point
range: Its range of value is beyond the scope of this discussion.
usage: Use a float if you need to save memory in large arrays of floating point numbers.
This data type should never be used for precise values, such as currency.
For that, you need to use the java.math.BigDecimal class instead.
6) double:
size: double-precision 64-Bit IEEE 754 floating point.
range: Its range of values is beyond the scope of this discussion.
usage: For decimal values, this data type is generally the default choice.
As mentioned above, this data type should never be used for precise values.
7) boolean:
size: represent one-bit of information, but its size isn't precisely defined.
range: true/false
usage: Use this data type for simple flags that track true/false conditions.
8) char:
size: 16-Bit = 2 Byte
range: '\u0000' or 0 inclusive ~ '\uffff' or 65535 inclusive
Default Values:
byte | 0 |
short | 0 |
int | 0 |
long | 0L |
float | 0.0f |
double | 0.0d |
char | '\u0000' |
String (or any object) | null |
boolean | false |
Reference Links:
1) http://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html
相关推荐
Java 中有两种基本数据类型:primitive types 和 reference types。primitive types 包括整数、浮点数、字符、布尔值等,而 reference types 则包括类和接口。primitive types 的值是存储在栈中的,而 reference ...
在Java编程语言中,原生类型(Primitive Types)是其语法结构的基础,它们不依赖于类或接口。本文将深入探讨Java中的四个整数类型:字节(Byte)、短整数(Short)、整数(Integer)和长整数(Long)。理解这些类型...
1. Java 变量和数据类型:在 Java 中,变量可以是基本类型(primitive types)或引用类型(reference types)。基本类型包括整数、浮点数、字符、布尔值等,而引用类型包括数组、类、接口等。Java 中的变量可以使用 ...
Supports: primitive types, multiple inner JSONArrays. Download get it and install from plugin repository or simply find it in "Preferences" -> "Plugins" -> "Browse Repositories" -> "RoboPOJOGenerator...
java编程基础,Java primitive data types and related subjects, such as variables, constants, data types, operators, and expressions. Control statements Array String
首先,Java中的数据类型分为两大类:基本数据类型(Primitive Data Types)和引用数据类型(Reference Data Types)。基本数据类型包括整型(如int)、浮点型(如float、double)、字符型(char)和布尔型(boolean...
Java有两大类数据类型:**原始数据类型(Primitive Data Types)**和**引用数据类型(Reference Data Types)**。原始数据类型包括: 1. **整型**(Integers):如`byte`, `short`, `int`, `long`,分别表示8位、16...
Item 61: Prefer primitive types to boxed primitives Item 62: Avoid strings where other types are more appropriate Item 63: Beware the performance of string concatenation Item 64: Refer to objects by ...
- **原始类型(Primitive Types)**:包括整数类型(byte, short, int, long)、浮点类型(float, double)和字符类型(char)以及布尔类型(boolean)。 - **引用类型(Reference Types)**:类、接口和数组,...
5. 基本数据类型(Primitive Data Types):Java 中的基本数据类型包括 byte、int、char、long、float、double、boolean 和 short。 6. String 和 StringBuffer 的区别:String 是不变的字符串,而 StringBuffer 是...
Java 中有两种基本数据类型:基本数据类型(primitive types)和引用数据类型(reference types)。 基本数据类型 基本数据类型包括: 1. 数值型(numeric type): byte, short, int, long, float, double 2. ...
在Java中,我们有两种主要的数据类型:基本数据类型(Primitive Data Types)和引用数据类型(Reference Data Types)。在"Sección 3 del Curso Java基础"这一章节中,我们将深入探讨这两种数据类型,并理解它们在...
Java中共有八种原始类型(Primitive Types),它们包括: 1. 整数类型:byte(1字节)、short(2字节)、int(4字节)和long(8字节)。 2. 浮点类型:float(4字节)和double(8字节)。 3. 字符类型:char(2字节...
- 原始类型(`Primitive Types`)不涉及引用复制。 - `java.lang.*` 被编译器隐式导入。 2. **数值表示**: - 十进制表示:`int decVal = 26;` - 十六进制表示:`int hexVal = 0x1a;` (等同于十进制的26) - ...
1. **原始类型**(Primitive Types):包括布尔型(`boolean`)、整型(如`int`、`byte`等)、字符型(`char`)以及浮点型(如`float`、`double`)。 - **整型**:包括`byte`、`short`、`int`、`long`,分别占用8...
*JAVA 中的变量可以是基本数据类型(primitive types)或引用类型(reference types) *基本数据类型包括整数(int)、浮点数(float)、字符(char)等 *引用类型包括数组、字符串、对象等 二、运算符 *JAVA 中的...
在类型、值和变量(Types, Values, and Variables)章节中,文档详细解释了Java类型系统的基础,包括各种类型和值的种类,其中既有基本类型(Primitive Types)也有引用类型(Reference Types),以及变量的定义和...