Skip to main content

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>

Comments

Popular posts from this blog

Architecture Complexity

Here are the items to consider: Coding to an interface Service Oriented Architecture Automated Testing Domain Driven Design Custom Data Access Layer Layered architecture Complexity is relatively equal the number of lines of code. Note that complexity is not bad. It must be justified.

Moving on

So I bought my self a 2.5″ hard drive enclosure for about 750 bucks. I wish I have my own tools for constructing a device as such. Instead of going for a 2GB USB flash drive, I chose to salvage the 30GB hard drive of an incapacitated laptop. Cool isn’t it? Though relatively slower than a typical USB flash drive, the storage capacity outweighs it. [To God] Thanks for being there always.

Bin to hex converter in 16-bit DOS assembly

Just a quick code like putting your keyboard where your brain is. There should be another way of doing this. I hate this code. start: xor al, al xor bl, bl xor cl, cl mov dl, 4 ; use dl as counter input: mov ah, 00 int 16h cmp ah, 1ch je exit cmp al, '0' jb input cmp al, '1' ja input convert: mov cl, dl dec cl ; dl - 1 sub al, 30h ; get original value shl al, cl ; place in the appropriate bit position or bl, al ; save in bl dec dl ; prepare for the next bit jnz input ; must be 4 bits cmp bl, 9 ja letter jbe number letter: add bl, 37h ; because 'A' - 37h is 0Ah jmp here number: add bl, 30h ; because '0' - 30h is 00h here: call display jmp start display: mov ah, 02h ...