Java Type Specs

guitarchanceΛογισμικό & κατασκευή λογ/κού

15 Αυγ 2012 (πριν από 8 χρόνια και 11 μήνες)

389 εμφανίσεις

Type

Spec
ification
s

in

Java

March 15, 2013

1

of
2

guitarchance_24c4f281
-
8338
-
495f
-
a25f
-
f0577ec33be8.docx

TypeSpecs
JV

Run on Windows 7 Home Premium 64
-
bit SP 1
;

Java JDK 7
with
NetBeans 7.0.1.

Int
eger Types

System.out.println(
"
\
n
BYTE
\
"
byte
\
"
"
);

1

System.out.println(
"Size is "

+ Byte.
SIZE

+
"

bits."
);

2

System.out.println(String.format(
"Max is %,d"
, Byte.
MAX_VALUE
));

3

System.out.println(String.format(
"Min is %,d "
, Byte.
MIN_VALUE
));

4

BYTE

"byte"

S
ize

is 8 bits.

Max is 127

Min is
-
128



5

System.out.println(
"
\
n
SHORT integer
\
"
short
\
"
"
);

6

System.out.println(
"Size is "

+ Short.
SIZE

+
" bits."
);

7

System.out.println(String.format(
"Max is %,d"
, Short.
MAX_VALUE
));

8

System.out.println(String.format(
"Min is %,d "
, Short.
MIN_VALUE
));

9

SHORT

integer "short"

S
ize

is 16 bits.

Max is 32,767

Min is
-
32,768



10

System.out.println(
"
\
n
INTEGER
\
"
int
\
"
"
);

11

System.out.println(
"Size is "

+ Integer.
SIZE

+
" bits."
);

12

System.out.println(String.format(
"Max is %,d"
, Integer.
MAX_VALUE
));

13

System.out.println(String.format(
"Min is %,d "
, Integer.
MIN_VALUE
));

14

INTEGER

"int"

S
ize

is 32 bits.

Max is 2,147,483,647

Min is
-
2,147,483,648


15

System.out.println(
"
\
n
LONG integer
\
"
long
\
"
"
);

16

System.out.println(
"Size is "

+ Long.
SIZE

+
" bits."
);

17

System.out.println(String.format(
"Max is %,d"
, Long.
MAX_VALUE
));

18

System.out.println(
String.format(
"Min is %,d "
, Long.
MIN_VALUE
));

19

LONG

integer "long"

S
ize

is 64 bits.

Max is 9,223,372,036,854,775,807

Min is
-
9,223,372,036,854,775,808


20

Character Type

21

System.out.println(
"
\
n
CHARACTER
\
"
char
\
"
"
);

22

System.out.println(
"Size is "

+ Character.
SIZ
E

+
" bits."
);

23

CHARACTER

"char"

char is an
Honorary Integer
..
.

S
ize

is
16

bits.



Type

Spec
ification
s

in

Java

March 15, 2013

2

of
2

guitarchance_24c4f281
-
8338
-
495f
-
a25f
-
f0577ec33be8.docx

Floating Point Types

System.out.println(
"
\
n
Single
-
precision FLOATing point
\
"
float
\
"
"
);

24

System.out.println(
"Size is "

+ Float.
SIZE

+
" bits."
);

25

System.out.println(
String.format(
"Max is %,f "
, Float.
MAX_VALUE
));

26

System.out.println(String.format(
"Min is %,f "
, Float.
MIN_VALUE
));

27

System.out.println(
"Special: "

+ Float.POSITIVE_INFINITY);

28

System.out.println(
"Special: "

+ Float.NEGATIVE_INFINITY);

29

System.out.println(
"Spe
cial:
\
"
Not a Number
\
"

"

+ Float.NaN);

30

Single
-
precision
FLOAT
ing point "float"

S
ize

is 32 bits.

Max is 340,282,346,638,528,860,000,000,000,000,000,000,000.000000

Min is 0.000000

Special: Infinity

Special:
-
Infinity

Special: "Not a Number" NaN

System.out.
println(
"
\
n
DOUBLE
-
precision floating point
\
"
double
\
"
"
);

31

System.out.println(
"Size is "

+ Double.
SIZE

+
" bits."
);

32

System.out.println(String.format(
"Max is %,f "
, Double.
MAX_VALUE
));

33

System.out.println(String.format(
"Min is %,f "
, Double.
MIN_VALUE
));

34

System.out.println(
"Special: "

+ Double.POSITIVE_INFINITY);

35

System.out.println(
"Special: "

+ Double.NEGATIVE_INFINITY);

36

System.out.println(
"Special:
\
"
Not a Number
\
"

"

+ Double.NaN);

37

DOUBLE
-
precision floating point "double"

S
ize

is 64 bits.

Max is
179,769,
313,486,231,570,000,000,000,000,000,000,000,000,000,000,000,000,0
00,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,00
0,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000
,000,000,000,000,000,000,000,000,000,000,000,
000,000,000,000,000,000,000,
000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,0
00,000,000,000,000,000,000,000,000,000,000,000.000000

Min is 0.000000

Special: Infinity

Special:
-
Infinity

Special: "Not a Number" NaN

Booleans

38

System.ou
t.println(
"
\
n
BOOLEAN
\
"
boolean
\
"
"
);

39

System.out.println(
"Size is JVM
[Java Virtual Machine]
dependent."
);

40

System.out.println(
"Only String along "

+ Boolean.toString(
true
));

41

BOOLEAN

"boolean"

S
ize

is JVM dependent.

String along
:

true

The String

42

System.out.println(
"/nSTRING
\
"
String
\
" An Honorary Primitive(?!?)"
);

43

String s =
"Pat"
;

44

System.out.println(
"Length is "

+ s.length());

45

STRING

"String"


An Honorary Primitive
(?!?)

Length is 3