0% found this document useful (0 votes)
16 views7 pages

CHP 5

Uploaded by

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

CHP 5

Uploaded by

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

Library Classes

Library Classes : Java library classes are inbuilt classes provided by java development kit
(JDK).
These class contain various packages, which are frequently used in java programming.
Eg: java.lang, java.io, java.math, etc.
Why class is called as composite data type?
A composite data type is one which is composed with various primitive data
types.
A class can contain various primitive data types as its data members so it is
known as a composite data type.

Primitive data type Non primitive or composite data


type or class types
They are inbuilt data type They are user defined datatypes
provided by Java compiler. composed of primitive datatypes
E.g. int, float double, etc E.g. class, array etc.
Class may be considered as anew data types created by the user, that has its
own functionality.
Class student
{
string name; // instance variables
int rollno, eng, hindi, math;
double per;
--------------
--------------
}
Wrapper Classes: A wrapper class wraps primitive data values in an object.
It is used for interconversion of string to primitive datatype and vice versa.
Java primitive data types are data values and not class objects. But sometimes we
may encounter situations where numerical values are needed but in the form of
objects.
Wrapper classes are part of java.lang package
Data Type Wrapper Class String sa = “5”;
String sb = “7.5”;
boolean Boolean (i) int a = Integer.parseInt(sa);
char Character or
int a = Integer.valueOf(sa);
byte Byte
short Short (ii) byte b = Byte.parseByte(sa);
or
int Integer byte b = Byte.valueOf(sa);
long Long
float Float
double Double Integer.parseInt( ); Integer.valueOf( );
It can only take a string as
It can only take a string as a well as an integer as
parameter. parameter.
It returns a primitive integer It returns an integer object.
value.
Primitive Datatype to string
1. int a = 5;
string s = Integer.toString(a); ….. “5”
2. long a = 710;
string s = Long.toString(a);
3. byte b = 7;
string s = Byte.toString(b);
4. short a = 10;
string s = Short.toString(a);
5. float f= 5.78;
string s = Float.toString(f);

You might also like