KEMBAR78
The Java Library Concept in Java Programming.pptx
JAVA LIBRARY
Mrs.R.Chinthamani
Assistant Professsor,
Department of Computer
Science
E.M.G.Yadava Women’s College
Java libraries
In java programming, main two features
are supported that is class and object. Basically
we know that class is collection of objects and
object is an instance of class. The uses of the
java libraries of class spread the programmer
efficiency by allowing computer programmer to
focus on the functionality unique to their job.
Library Classes
The java programmer for developing their
programming logic as well as their programming
architecture with very smooth and very fine way.
These classes are called Library Classes.
In Java support thousands of library classes and
also each class contains various types of functions.
Advantages of Library Classes in Java
The type constraints are used to control where the java library classes can
be replaced with routine versions without affecting type perfection of
programs.
Static analysis is then used to control those applicants for which unused
library functionality and synchronization can be removed
safely from the allocated types.
The profile data is collected about the usage features of the customization
candidates to determine where the allocation of custom library classes is
likely to be cost-effective.
To base on the static analysis results and the profiling information the
custom library classes are automatically generated from a template.
The bytecode of the client application is rewritten to use the generated
List of Library Classes in Java
Library classes Purpose of the class
Java.io Use for input and output
functions.
Java.lang Use for character and string
operation.
Java.awt Use for windows interface.
Java.util Use for develop utility programming.
Java.net Used for network communication.
Java.math Used for various mathematical
Process to Input / Output operation in JAVA:
Java languages do not provide specific
statement to input a value from the keyboard or to
print the result on the visual display unit [VDU]. It uses
the functions read() to accept a character from the
keyboard and print() or println() to display the result on
the screen.
Methods Summary: Class Math
Library classes function Purpose of the class
abs(double a)
Used to return the absolute value of the
double value.
abs(float a)
Used to return the absolute value of the float
value.
abs(int a)
Used to return the absolute value of an int
value.
abs(long a)
Used to return the absolute value of a long
value.
acos(double a)
Used to return the arc cosine of an angle, in
the range of 0.0 through pi
asin(double a)
Returns the arc sine of an angle, in the range
of −pi/2 through pi/2
atan(double a)
Used to return the arc tangent of an angle, in
the range of −pi/2 through pi/2
atan2(double y, double x) Converts rectangular coordinates (x, y) to polar (r, theta)
cbrt(double a) Used to return the cube root of a double value
ceil(double a)
Used to return the smallest (closest to negative infinity) double value that is
greater than or equal to the argument and is equal to a mathematical integer
cos(double a) Used to return the trigonometric cosine of an angle
cosh(double x) Used to return the hyperbolic cosine of a double value
exp(double a) Used to return Euler’s number e raised to the power of a double value
expm1(double x) Used to return ex 1
−
floor(double a)
Used to return the largest (closest to positive infinity) double value that is less
than or equal to the argument and is equal to a mathematical integer than or
hypot(double x, double y)
Used to return sqrt(x2 + y2) without intermediate
overflow or underflow
IEEEremainder(double f1, double f2)
Computes the remainder operation on two arguments
as prescribed by the IEEE 754 standard
log(double a)
Used to return the natural logarithm (base e) of a
double value
log10(double a) Used to return the base 10 logarithm of a double value
log1p(double x)
Used to return the natural logarithm of the sum of the
argument and 1
max(double a, double b) Used to return the greater of two double values
max(float a, float b) Used to return the greater of two float values
max(int a, int b) Used to return the greater of two int values
max(long a, long b) Used to return the greater of two long values
min(double a, double b) Used to return the smaller of two double values
min(float a, float b) Used to return the smaller of two float values
min(int a, int b) Used to return the smaller of two int values
min(long a, long b) Used to return the smaller of two long values
pow(double a, double b)
Used to return the value of the first argument raised to
the power of the second argument
random()
Used to return a double value with a positive sign,
greater than or equal to 0.0 and less than 1.0.
rint(double a)
Used to return the double value that is closest in value
to the argument and is equal to a mathematical integer
round(double a) Used to return the closest long to the argument
round(float a) Used to return the closest int to the argument
signum(double d)
Used to return the signum function of the argument;
zero if the argument is zero, 1.0 if the argument is
greater than zero, and 1.0 if the argument is less than
−
zero
signum(float f)
Used to return the signum function of the argument;
zero if the argument is zero, 1.0f if the argument is
greater than zero, and 1.0f if the argument is less
−
than zero
sin(double a) Used to return the trigonometric sine of an angle
sqrt(double a)
Used to return the correctly rounded positive square root of a
double value
tan(double a) Used to return the trigonometric tangent of an angle
tanh(double x) Used to return the hyperbolic tangent of a double value
toDegrees(double angrad)
Converts an angle measured in radians into an approximately
equivalent angle measured in degrees
toRadians(double angdeg)
Converts an angle measured in degrees into an approximately
equivalent angle measured in radians
ulp(double d) Used to return the size of an ulp of the argument
ulp(float f) Used to return the size of an ulp of the argument
The Math Library
No need to know how they are implemented.
Contains constants such as E and PI.
To access:
Math.x or Math.m() , where x stands for the name
of the constant / m for the name of the method you want
to use
Math Library Examples
Variable declaration
double
positiveNumber ;
Variable initialiation
double positiveNumber = Math.abs(-10);
For each method it lists what the method needs as
input and what it returns as output.
SOME MORE EXAMPLES
double twoCubed = Math.pow(2,3);
double someTrigThingy = Math.sin(Math.PI);
How to Call a Static Method
Syntax :
Name of Class . Name of Method ( Parameter )
(Values for each Parameter , Separated by Commas)
Parentheses are mandatory, even if there are no
Parameters!
Method declaration using STATIC with MATH
FUNCTIONS
Key
word
(Static)
Return
Type , i.e.
what the
Method
Produces
as Output
Name
of the
Metho
d
Method
Paramete
rs, i.e.
What the
Method
requires
as input
Examples :
static double sin(double a)
static double sqrt(double a)
static double pow(double a,
double b)
static int abs(int a)
static int max(int a, int b)
Example Program for Both STATIC MEMBER AND
MATH LIBRARIES
Class MathFunction
{
static float Mul (float x, float y)
{
return x * y ;
}
static float Divide (float x, float y)
{
return x * y ;
}
}
Class MathApplication
{
public static void main (string args [ ] )
{
float a = MathFunction . Mul ( 4.0 , 5.0 ) ;
float b = MathFunction . Divide ( a , 2.0 ) ;
}
}
OUTPUT :
b = 10.0
THANK YOU

The Java Library Concept in Java Programming.pptx

  • 1.
    JAVA LIBRARY Mrs.R.Chinthamani Assistant Professsor, Departmentof Computer Science E.M.G.Yadava Women’s College
  • 2.
    Java libraries In javaprogramming, main two features are supported that is class and object. Basically we know that class is collection of objects and object is an instance of class. The uses of the java libraries of class spread the programmer efficiency by allowing computer programmer to focus on the functionality unique to their job.
  • 3.
    Library Classes The javaprogrammer for developing their programming logic as well as their programming architecture with very smooth and very fine way. These classes are called Library Classes. In Java support thousands of library classes and also each class contains various types of functions.
  • 4.
    Advantages of LibraryClasses in Java The type constraints are used to control where the java library classes can be replaced with routine versions without affecting type perfection of programs. Static analysis is then used to control those applicants for which unused library functionality and synchronization can be removed safely from the allocated types. The profile data is collected about the usage features of the customization candidates to determine where the allocation of custom library classes is likely to be cost-effective. To base on the static analysis results and the profiling information the custom library classes are automatically generated from a template. The bytecode of the client application is rewritten to use the generated
  • 5.
    List of LibraryClasses in Java Library classes Purpose of the class Java.io Use for input and output functions. Java.lang Use for character and string operation. Java.awt Use for windows interface. Java.util Use for develop utility programming. Java.net Used for network communication. Java.math Used for various mathematical
  • 6.
    Process to Input/ Output operation in JAVA: Java languages do not provide specific statement to input a value from the keyboard or to print the result on the visual display unit [VDU]. It uses the functions read() to accept a character from the keyboard and print() or println() to display the result on the screen.
  • 7.
    Methods Summary: ClassMath Library classes function Purpose of the class abs(double a) Used to return the absolute value of the double value. abs(float a) Used to return the absolute value of the float value. abs(int a) Used to return the absolute value of an int value. abs(long a) Used to return the absolute value of a long value. acos(double a) Used to return the arc cosine of an angle, in the range of 0.0 through pi asin(double a) Returns the arc sine of an angle, in the range of −pi/2 through pi/2 atan(double a) Used to return the arc tangent of an angle, in the range of −pi/2 through pi/2
  • 8.
    atan2(double y, doublex) Converts rectangular coordinates (x, y) to polar (r, theta) cbrt(double a) Used to return the cube root of a double value ceil(double a) Used to return the smallest (closest to negative infinity) double value that is greater than or equal to the argument and is equal to a mathematical integer cos(double a) Used to return the trigonometric cosine of an angle cosh(double x) Used to return the hyperbolic cosine of a double value exp(double a) Used to return Euler’s number e raised to the power of a double value expm1(double x) Used to return ex 1 − floor(double a) Used to return the largest (closest to positive infinity) double value that is less than or equal to the argument and is equal to a mathematical integer than or
  • 9.
    hypot(double x, doubley) Used to return sqrt(x2 + y2) without intermediate overflow or underflow IEEEremainder(double f1, double f2) Computes the remainder operation on two arguments as prescribed by the IEEE 754 standard log(double a) Used to return the natural logarithm (base e) of a double value log10(double a) Used to return the base 10 logarithm of a double value log1p(double x) Used to return the natural logarithm of the sum of the argument and 1 max(double a, double b) Used to return the greater of two double values max(float a, float b) Used to return the greater of two float values max(int a, int b) Used to return the greater of two int values
  • 10.
    max(long a, longb) Used to return the greater of two long values min(double a, double b) Used to return the smaller of two double values min(float a, float b) Used to return the smaller of two float values min(int a, int b) Used to return the smaller of two int values min(long a, long b) Used to return the smaller of two long values pow(double a, double b) Used to return the value of the first argument raised to the power of the second argument random() Used to return a double value with a positive sign, greater than or equal to 0.0 and less than 1.0. rint(double a) Used to return the double value that is closest in value to the argument and is equal to a mathematical integer
  • 11.
    round(double a) Usedto return the closest long to the argument round(float a) Used to return the closest int to the argument signum(double d) Used to return the signum function of the argument; zero if the argument is zero, 1.0 if the argument is greater than zero, and 1.0 if the argument is less than − zero signum(float f) Used to return the signum function of the argument; zero if the argument is zero, 1.0f if the argument is greater than zero, and 1.0f if the argument is less − than zero sin(double a) Used to return the trigonometric sine of an angle
  • 12.
    sqrt(double a) Used toreturn the correctly rounded positive square root of a double value tan(double a) Used to return the trigonometric tangent of an angle tanh(double x) Used to return the hyperbolic tangent of a double value toDegrees(double angrad) Converts an angle measured in radians into an approximately equivalent angle measured in degrees toRadians(double angdeg) Converts an angle measured in degrees into an approximately equivalent angle measured in radians ulp(double d) Used to return the size of an ulp of the argument ulp(float f) Used to return the size of an ulp of the argument
  • 13.
    The Math Library Noneed to know how they are implemented. Contains constants such as E and PI. To access: Math.x or Math.m() , where x stands for the name of the constant / m for the name of the method you want to use
  • 14.
    Math Library Examples Variabledeclaration double positiveNumber ; Variable initialiation double positiveNumber = Math.abs(-10);
  • 15.
    For each methodit lists what the method needs as input and what it returns as output. SOME MORE EXAMPLES double twoCubed = Math.pow(2,3); double someTrigThingy = Math.sin(Math.PI);
  • 16.
    How to Calla Static Method Syntax : Name of Class . Name of Method ( Parameter ) (Values for each Parameter , Separated by Commas) Parentheses are mandatory, even if there are no Parameters!
  • 17.
    Method declaration usingSTATIC with MATH FUNCTIONS Key word (Static) Return Type , i.e. what the Method Produces as Output Name of the Metho d Method Paramete rs, i.e. What the Method requires as input Examples : static double sin(double a) static double sqrt(double a) static double pow(double a, double b) static int abs(int a) static int max(int a, int b)
  • 18.
    Example Program forBoth STATIC MEMBER AND MATH LIBRARIES Class MathFunction { static float Mul (float x, float y) { return x * y ; } static float Divide (float x, float y) {
  • 19.
    return x *y ; } } Class MathApplication { public static void main (string args [ ] ) { float a = MathFunction . Mul ( 4.0 , 5.0 ) ; float b = MathFunction . Divide ( a , 2.0 ) ; } }
  • 20.
  • 21.