♠ Posted by Unknown in Core Java at 23:11
Java Constants and Datatypes
JAVA (CONSTANTS) :-
1. Numeric Constants
a. Integer
Constants :- 123, -321, 0, 654321,
Octal, Hexadecimal
b. Real
Constants :- 0.0083, -0.75, 435.36, 0.65e4, 12e-2, 1.5e+5
2. Character Constants
a. Single
Character Constants :- ‘5’, ‘X’, ‘;’, ‘ ‘
b. String
Constants :- “Hello Java”, “1997”, “?....!”, “5+3”, “X”
JAVA (DATATYPES) :-
1. primitive (Intrinsic) :
a. Numeric :
i. Integer
1. Byte (1
byte) -128 to +127
2. Short (2
bytes) -32,768 to +32,767
3. int (4
bytes) -2,147,483,648 to +2,147,483,647
4. long (8
bytes) -9,223,372,036,854,775,808 to +9,223,372,036,854,775,807
ii. Floating
Point
1. float (4
bytes) 3.4e-038 to 3.4e+038
2. double (8
bytes) 1.7e-308 to 1.7e+308
b. Non-Numeric :
i. Character
(2 bytes) Holds singles character only
ii. Boolean
(1 bit) Holds Only true or false
2. Non-primitive :
a. Classes
b. Interface
c. Arrays
Characters :-
In Java, the data type used to sore characters
is char. However C/C++ programmers beware: char in Java is not
the same as char in C/C++. In C/C++, char is an integer type that
is 8 bits wide. This is not the case in Java. Instead, Java uses Unicode
to represent characters. Unicode defines a fully international character
set that can represent all of the characters found in all human languages. It
is a unification of dozens of character set, such as Latin, Greek, Arabic,
Cyrillic, Hebrew, Katakana, Hangul, and many more. For this purpose, it
requires 16 bits. Thus, in Java char is a 16-bit type (2 bytes). The
range of a char is 0 to 65,536. There are no negative chars. The
standard set of characters known as ASCII still ranges from 0 to 127 as always,
and the extended 8-bit character set, ISO-Latin-1, ranges from 0 to 255. Since
Java is designed to allow applets to be written for worldwide use, it makes
sense that it would use Unicode to represent characters. Of course, the use of
Unicode is somewhat inefficient for languages such as English, German, Spanish,
or French whose characters can easily be contained within 8 bits. But such is
the price that must be pain for global portability.
0 comments:
Post a Comment