Digital Stronghold - Software Engineering Blog




May 5, 2008

Primitive Data Types in Java

Java supports 8 built-in data types.

boolean - This data type is 1 bit in size and is used to represent a binary
condition, true or false.

byte - This data type is an 8-bit signed 2’s complement integer.
It can hold values ranging from -128 to 127.

short - This data type is a 16-bit signed 2’s complement integer.
It can hold values ranging from -32,768 to 32,767.

char - This data type is a 16-bit unsigned integer used to represent unicode characters.
It can hold values ranging from 0 to 65,535.

int - This data type is a 32-bit signed 2’s complement integer.
It can hold values ranging from -2,147,483,648 to 2,147,483,647.

long - This data type is a 64-bit signed 2’s complement integer.
It can hold values raging from -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807.

float - This data type is a 32-bit signed floating-point number.
The range of values it can hold is +/–3.40282347^38.

double - This data type is a 64-bit signed floating-point number.
The range of values it can hold is +/–1.79769313486231570^308.

The syntax for declaring and initializing a primitive is:

<modifier> <type> <variableName> = <initialvalue>

2 Comments »

The URI to TrackBack this entry is: http://eradicus.blogsome.com/2008/05/05/primitive-data-types-in-java/trackback/

  1. and how exactly would implement a 1bit variable internally in java?

    Comment by Foo Bar — May 5, 2008 @ 8:46 pm

  2. check this out,

    http://forum.java.sun.com/thread.jspa?threadID=412598&messageID=1816190

    Comment by Joset Anthony Zamora — May 6, 2008 @ 7:29 am

RSS feed for comments on this post.

Leave a comment

Line and paragraph breaks automatic, e-mail address never displayed, HTML allowed: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>



Anti-spam measure: please retype the above text into the box provided.

Theme designed by Joset Anthony Zamora


Digital Stronghold

↑ Get Headline Animator