0% found this document useful (0 votes)
11 views2 pages

4 DataType

The document outlines various data types in programming, categorizing them into primitive and non-primitive types. It details the size, bit representation, wrapper classes, default values, and range for each primitive type such as byte, short, int, long, float, double, char, and boolean. Additionally, it explains the concept of variables, their declaration, initialization, and provides a formula for calculating the range of data types based on their bit size.

Uploaded by

g.farhanmohd2
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views2 pages

4 DataType

The document outlines various data types in programming, categorizing them into primitive and non-primitive types. It details the size, bit representation, wrapper classes, default values, and range for each primitive type such as byte, short, int, long, float, double, char, and boolean. Additionally, it explains the concept of variables, their declaration, initialization, and provides a formula for calculating the range of data types based on their bit size.

Uploaded by

g.farhanmohd2
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

data types

==========
Primitive
===========
Wrapperclass--------------classes of primitive datatype

dataType| Size| bit WrapperClass DefaultValue MIN


AND MAX max digits

byte 1 8 Byte 0
-128---to---127 ---2 digits 99
short 2 16 Short 0
32767 ---4 digits 9999
int 4 32 Integer 0
---9 digits 999999999
long 8 64 Long 0
9876543210l ---19digits 99999999999999L

float 4 32 Float 0.0


78.0f 54637347437437.564f 7dec
double 8 64 Double 0.0
6474.047464--15dec

char - '' 2 16 Charater \u0000


'a'

boolean 1 8 Boolen false /true

non-primitive data type


========================
String - " " null

String(predefinded class)---(java.lang-package)
-------------------------
"Collection of charater" "J a v a 2 0" Collections of characters within a
double quotes is called as String

variable----name of memory location where data get stored (camel notation)


-it helps to store the values/data's

a=100;

declaration
------------
datatype varaible Name;
eg:int age;

initilaization
--------------
variableName =value; (directly intilaization is not possible in java)
eg:age=22;

declaration & initilization


---------------------------
datatype variableName=value; int age=22;
-----------------------------------------------------------------------------------
---------------------------------------------------------------------
Range calculating formula
---------------------------
-2^[n-1] to (2^[n-1])-1

n--bit

Byte-->n=8

-2^[8-1] to (2^[8-1])-1

-2^7 to (2^7)-1

-128 to 127-------------2 digit

Short-->n=16
-------------

-2^[16-1] to (2^[16-1])-1

-2^15 to (2^15)-1

-32768 to 32767-------------4 digts max

You might also like