Data type and Wrapper class in java

DATAYPE AND WRAPPER CLASS

DATATYPE

  • Java language support the concept of primitive datatype like c or c++
  • If a language support primitive datatype that language cannot be a pure object oriented programming language.
  • To make java language pure object oriented it supports the concept of wrapper class.
  • As java language support the concept of architecture neutral the size of primitive data type is fixed for all the environment.

WRAPPER CLASS

  • For each datatype java provide a predefined class ,technically known as wrapper class in java.
  • Wrapper class are used to convert data type an object .In java primitive datatype are not object they don’t belongs to any class.
  • All the wrapper class present in java.lang package.
  • Wrapper class are also used for type conversion.
  • All the wrapper class are final class it can’t be inherited.
DATATYPESWRAPPER CLASS

SIZE

DEFAULT VALUE
byteByte8bits0
charCharacter16bits/u
shortShort16bits0
intInteger32bits0
longLong64bits0L/0l
floatFloat32bits0.0f
doubleDouble64bits0.0
BooleanBoolean1bitfalse

NOTE  Signed and unsigned keyword are not available in java like c or c++,by default datatype is always signed in nature.

PARSEBYTE( ) –This is a static method present in byte wrapper class which is used to convert a string to a byte type.

TOSTRING( )- This is a predefined static method present in each wrapper class which convert a datatype to string format.

charAt( )- This method is used to get character of a specific index.

ToBinaryString( )- This method is convert integer to binary  and return value into a string format.

toOctalString( )- This method is convert integer to octal and return value into a string format.

toHexaString( )-This method is convert integer to hexadecimal and return value into a string format.

CurrentTimeMillis( )-It is a predefined static method present in system class which always return the system time in mill sec format.

 

 

basicittopic

basicittopic

A Computer Science Study for IT students and people of IT community

6 thoughts on “Data type and Wrapper class in java

Leave a Reply