Packages are collection of classes.
The built in packages of java development kits are as follows:
1) java.lang => lang means language package. It contains all the essential parts of java programming, example System.out.println, System.out, System.in.
*It also contains all the mathematical library functions like Math.pow,Math.rint,Math.round,Math.ceil,Math.floor etc,
*all the String functions such as length(),charAt(),substring(), trim(), toUpperCase() etc,
*all the Character functions such as Character.toUpperCase,Character.isLetter,Character.isDigit etc
2) java.util => util means utility package, this contains methods like data structures such as stack,queue,linkedlist etc and it also contains input/output classes like Scanner.
3) java.net => net means network package. This contains all the methods which are required to develop applications using the network for communications example such websockets etc.
4) java.applet => this contains the methods and classes to develop online graphical user interface based softwares/applications.
5) java.awt => awt stands for abstract window toolkit, It is used to develop desktop based graphical userface applications.
Wrapper Classes: are the non-primitive/object based equivalent of the primitive data type.
Primitive Non-Primitive/Wrapper Class
byte Byte
short Short
int Integer
long Long
float Float
double Double
char Character
boolean Boolean
Autoboxing/Boxing: It is process of convertion of primitive to non-primitive datatype and vice vesa.
Examples of autoboxing
———————–
a) int a = 5;
Integer b = a; //Here 5 has now become a object based data structure
(Another way)
Integer b = Integer.valueOf(a);
b) short b = 7;
Short y = b;
or
Short y = Short.valueOf(b);
c) char ch = ‘A’;
Character d = ch;
or
Character d = Character.valueOf(d);
d) double y = 55.6;
Double x = y;
or
Double x = Double.valueOf(d);
Unboxing : The reverse process of non-primitive to primitive data type.
——–
Examples of unboxing
———————
a) Integer z = 5;
int b = z;
b) Float m = 125.5f;
float n = m;
Primitive/Non-Primitive datatypes to String
—————————–
(a) int to String
int a = 835;
String b = Integer.toString(a); => “835”
String b = String.valueOf(a); => “835”;
(b) Integer to String
Integer a = 75;
String b = Integer.toString(a); => “75”
String b = String.valueOf(a); => “75”;
(c) byte to String
byte a = 83b;
String b = Byte.toString(a); => “83”
String b = String.valueOf(a); => “83”;
(d) Byte to String
Byte a = 75b;
String b = Byte.toString(a); => “75”
String b = String.valueOf(a); => “75”;
(e) short to String
short a = 83s;
String b = Short.toString(a); => “83”
String b = String.valueOf(a); => “83”;
(f) Short to String
Short a = 75s;
String b = Short.toString(a); => “75”
String b = String.valueOf(a); => “75”;
(g) long to String
long a = 83l;
String b = Long.toString(a); => “83”
String b = String.valueOf(a); => “83”;
(h) Long to String
Long a = 75l;
String b = Long.toString(a); => “75”
String b = String.valueOf(a); => “75”;
(i) float to String
float a = 83.5f;
String b = Float.toString(a); => “83.5”
String b = String.valueOf(a); => “83.5”;
(j) Float to String
Float a = 75.5F; or 75.5f;
String b = Float.toString(a); => “75.5”
String b = String.valueOf(a); => “75.5”;
(k) double to String
double a = 83.5; or 83.5d; or 83.5D;
String b = Double.toString(a); => “83.5”
String b = String.valueOf(a); => “83.5”;
(l) Double to String
Double a = 83.5; or 83.5d; or 83.5D;
String b = Double.toString(a); => “75.5”
String b = String.valueOf(a); => “75.5”;
(m) char to String
char ch = ‘A’;
String m = Character.toString(ch); =>”A”
String m = “”+ch; => “A”
(n) Character to String
Character ch = ‘A’;
String m = Character.toString(ch); =>”A”
String m = ch.toString(); => “A”
String m = “”+ch; => “A”
Character Functions
——————-
1) Character.toUpperCase(char) return type char
This functions convert all the letter to capital/uppercase(‘A’-‘Z’) letter
Examples:
(i) Character.toUpperCase(‘a’) => ‘A’
(ii) Character.toUpperCase(‘A’) => ‘A’
(iii) Character.toUpperCase(97) => 65 (because 97 is ascii code ‘a’)
(iv) Character.toUpperCase(‘?’) => ‘?’
(v) Character.toUpperCase(‘2’) => ‘2’
2) Character.toLowerCase(char) return type char
This functions convert all the letter to small/lowercase(‘a’-‘z’) letter
Examples:
(i) Character.toLowerCase(‘a’) => ‘a’
(ii) Character.toLowerCase(‘A’) => ‘a’
(iii) Character.toLowerCase(66) => 98 (because 66 is ascii code ‘B’)
(iv) Character.toLowerCase(‘?’) => ‘?’
(v) Character.toLowerCase(‘2’) => ‘2’
3) Character.isUpperCase(ch) return type boolean
This functions will return true if the letter is capital/uppercase(‘A’-‘Z’) or ASCII with the range of 65-90(in case of A-Z) otherwise will return false
Examples:
(i) Character.isUpperCase(‘a’) => false
(ii) Character.isUpperCase(‘A’) => true
(iii) Character.isUpperCase(97) => false (because 97 is ascii code ‘a’)
(iv) Character.isUpperCase(‘?’) => false
(v) Character.isUpperCase(‘2’) => false
4) Character.isLowerCase(ch) return type boolean
This functions will return true if the letter is lowercase/small(‘a’-‘z’) or ASCII with the range of 97-122(in case of a-z) otherwise will return false
Examples:
(i) Character.isLowerCase(‘a’) => true
(ii) Character.isLowerCase(‘A’) => false
(iii) Character.isLowerCase(66) => false (because 66 is ascii code ‘B’)
(iv) Character.isLowerCase(‘?’) => false
(v) Character.isLowerCase(‘2’) => false
5) Character.isLetter(ch) return type boolean
This functions will return true if the character is a letter(‘A’-‘Z’/’a’-‘z’) otherwise will return false
Examples:
(i) Character.isLetter(‘a’) => true
(ii) Character.isLetter(‘A’) => true
(iii) Character.isLetter(66) => true(because 66 is ascii code ‘B’)
(iv) Character.isLetter(‘?’) => false
(v) Character.isLetter(‘2’) => false
6) Character.isDigit(ch) return type boolean
This functions will return true if the character is a digit(‘0’-‘9’) otherwise will return false
Examples:
(i) Character.isDigit(‘a’) => false
(ii) Character.isDigit(‘A’) => false
(iii) Character.isDigit(57) => true (because 57 is ascii code ‘9’)
(iv) Character.isDigit(‘?’) => false
(v) Character.isDigit(‘2’) => true
7) Character.isLetterOrDigit(ch) return type boolean
This functions will return true if the character is a letter/digit(‘A’-‘Z’/’a’-‘z’/’0’-‘9’) or ASCII with the range of 65-90(in case of A-Z), 97-122(in case of a-z) and 48-57(‘0’-‘9’) otherwise will return false
Examples:
(i) Character.isLetterOrDigit(‘a’) => true
(ii) Character.isLetterOrDigit(‘A’) => true
(iii) Character.isLetterOrDigit(57) => true (because 57 is ascii code ‘9’)
(iv) Character.isLetterOrDigit(‘?’) => false
(v) Character.isLetterOrDigit(‘2’) => true
8) Character.isWhitespace(ch) return type boolean
This function will return true if the character is a blank space(‘ ‘) or ASCII code 32
Examples
(i) Character.isWhitespace(32) => true (32 is the ascii code of whitespace ‘ ‘)
(ii) Character.isWhitespace(‘ ‘) => true
(iii) Character.isWhitespace(‘A’) => false