7using library class
7using library class
Library
Classes
Introduction
• A class created by user is known as User defined class.
• But, there are some classes available with Java System, which
provide an effective support to the programmers in developing
their logic. These classes are called as Library Classes.
• There are various library classes in Java and each class includes
various functions.
Some Library Classes
a = System.in.read();
Here,
System.in is an input stream belonging to the System class which in turn
is an object of input stream class available in java.io package.
• To print the result the print function can be written as :
System.out.print(a);
or
System.out.println(a);
Here, System. out() is an output stream belonging to the System class which
in turn is an object of print stream class available in java.io package.
Stream
• A stream is a group of data (characters/byte).
• Types :
2) System. out
3) System.err
• System. out and System.err are output streams related with monitor/screen.
• The finally block contains the statements which are executed any
way.
Syntax
try
{
set of statements
}
catch (exception e) {}
finally
{
statement to execute anyway
}
DEMO
Wrapper Classes
• These classes provide the facilities to contain primitive data
values in terms of objects.
Character char
Byte byte
Short short
Integer int
Long long
Float float
Double double
Packages In Java
• A package is a group of classes, which can be imported to a
program so that user may exercise the implicit facility available in it.
• E.g.
import java.io.*; => It allows all the classes of this package to be
included.
• E.g.
import java.io.*; => It allows all the classes of this package to be included.
}
class square
{
}
class circle
{