07 October 2010

0 Primitive Data Types in Java

Integer Data Types in JAVA

byte- 1 byte
short- 2 bytes
int- 4 bytes
long- 8 bytes

Floating Data Types in JAVA

float- 4 bytes
double- 8 bytes

Textual Data Types in JAVA

char- 2 bytes
The char data type in Java is 2 bytes because it uses UNICODE character set to support internationalization.

Logical Data Types in JAVA

boolean- 1 byte (true/false)

All numeric data types are signed
The size of data types remain the same on all platforms

UNICODE is a character set which covers all known scripts and language in the world.

Declaring and using primitive data types is Java similar to that of C.
int iCount;
int flag=100;

Unlike C, in Java variables can be declared anywhere in the program. and the best practice is Declare a variable in program only when required. Do not declare variables upfront like in C.

In Java, if a local variable is used without initializing it, the compiler will show an error.


0 comments:

Feeds Comments

Please give your valuable comments.