Library Classes
Library Classes
DEPARTMENTOF ASSAMVALLEY
LIBRARY CLASSES IN JAVA
Java Class Library (JCL):
1
libraries that Java applications he Java Class is a set of dynamicaljv loadable
can call at run time. These classes arc grouped in different
Java packages.
Package: Package in Java is
a mechanism to encapsulatea group of classes, sub packagesand
21 Page
METHODS OF
WRAPPER CLASSES:
Return
Method
Type Description
boolean Character ist otter()
boolean Checks whether thc character a Ictter or not.
Checks whether the character is a digit or not.
boolean Character.istettcrOrDtglt() This function returns true if the gjven argument is either a
Ictter or digit.
boolean Character.isWhiteSpace() This function returns true if the given argument is a white
space.
boolean Character.isUpperCase() This function returns true if the given argument is a upper
case letter.
boolean Character.isLowerCase() This function returns true if the given argument is a lower
case letter.
CONVERTING UPPER CASE LETTERS TO LOWERCASE AND VICE VERSA
Character Character.toUpperCase(char c) This method takes a character as parameter and returns the
character in lower case.
Character Character-toLowerCase(char c) This method takes a character as parameter and returns the
character in upper case.
PARSING OR DECODING PRIMITIVE TYPE FROM STRING
int parselnt(String) Takes String and converts it to a primitive "int" type number.
long parseLong(String) Takes String and converts it to a primitive "long" type number.
float parseFloat(String) Takes String and converts it to a primitive "float" type number.
Double parseDouble(String) Takes String and converts it to a primitive "double" type number.
Example:
or lower) otherwise check whether it is a digit or
Program to accept a character and check the case (upper
special character.
Answer:
import Scanner-util.*
public class char_ check
char ch;
void main()throws IOException
31 Page
System.out.println(ch f" is a letter");
else
char a= •m;
char b= 'M';
char upper= character.toUpperCase(a); // value of variable upper is now uppercase M
char lower= character.toLowerCase(b); // value of variable lower is now uppercase m
Character.isLetterOrDigit() example:
41 Page
AUTOBOXING AND
UNBOXtNG:
Autoboxing: Automatic
is known as conversion of primitive types to the object
autoboxing. Vor example — of their correspondingwrapperclasses
conversion of int to Integer, long to Long, double to Double etc.
Example:
Integer auto=9;
System.out.println(: The value of auto is:"+auto);
Output: 9
Unboxing: It is just the reverse process of autoboxing.Automaticallyconvertingan objectof a wrapper
class to its corresponding primitive type is known as unboxing. For example —conversion of Integerto int,
Long to long, Double to double etc.
Example:
Integer auto—newInteger(S);
int k=auto;
System.out.println(: The value of auto is:"+k)
Output: 5
51 P age