Data Types
THE Java programming language is a strongly typed (not keyboard typing it’s a Data Types)) language, which means that every variable and every expression has a type (data type) that is known at compile time.
Types limit the values that a variable can hold or that an expression can produce, limit the operations supported on those values, and determine the meaning of the operations. Strong typing helps detect errors at compile time.
The types of the Java programming language are divided into two categories:
The primitive types are
the boolean type and
the numeric types.
The numeric types are
the integral type’s
byte, short, int, long, and char, and
the floating-point types
`float and double.
There is also a special null type
4.1 The Kinds of Types and Values
There are two kinds of data types in the Java programming language:
primitive types and
reference types . correspondingly,
There are, two kinds of data values that can be stored in variables, passed as arguments,returned by methods, and operated on:
primitive values and
Reference values
There is also a special null type
the type of the expression null, which has no name. Because the null type has no name, it is impossible to declare a variable of the null type or to cast to the null type. The null reference is the only possible value of an expression of null type. The null reference can always be cast to any reference type.
In practice, the programmer can ignore the null type and just pretend that null is merely a special literal that can be of any reference type
4.2 Primitive Types and Values
A primitive type is predefined by the Java programming language and named by its reserved keyword
Primitive Type: 1) Numeric Type 2) boolean type The boolean type has exactly two values: true and false Numeric Type: 1) Integral Type 2) Floating Point Type Integral Type: one of byte ,short, int ,long ,char Floating Point Type: one of float ,double |
The numeric types are the
integral types and the
floating-point types.
The integral types are byte, short, int, and long, whose values are 8-bit,
16-bit, 32-bit and 64-bit signed two’s-complement integers, respectively, and
char, whose values are 16-bit unsigned integers representing UTF-16 code units
The floating-point types are float, whose values include the 32-bit IEEE 754
floating-point numbers, and double, whose values include the 64-bit IEEE 754
floating-point numbers.
The boolean type has exactly two values: true and false
4.2.1)Integral Types and Values
The values of the integral types are integers in the following ranges:
• For byte, from –128 to 127, inclusive
• For short, from –32768 to 32767, inclusive
• For int, from –2147483648 to 2147483647, inclusive
• For long, from –9223372036854775808 to 9223372036854775807
• For char, from '\u0000' to '\uffff' inclusive, that is, from 0 to 65535
4.2.2 Integer Operations
4.2.3 Floating-Point Types, Formats, and Values
The floating-point types are
float, whose values include the 32-bit IEEE 754 floating-point numbers, and
double, whose values include the 64-bit IEEE 754 floating-point numbers.
4.2.4 Floating-Point Operations
4.2.5 The boolean Type and boolean Values
The boolean type represents a logical quantity with two possible values, indicated by the literals true and false (§3.10.3).
4.3 Reference Types and Values
There are three kinds of reference types:
class types (§8),
interface types (§9), and
array types (§10).
Reference types may be parameterized (§4.5) with type arguments (§4.4).
The reference types are
class types,
interface types, and
array types. There is also a special
null type.
No comments:
Post a Comment