StringBuffer:----
----------------------
1)StringBuffer is a class present in the [Link] package
2)StringBuffer is also a final class, so it can not be inherit
3)SB is a mutable class so it is possible to change the content in the same
location
Constructors:----
----------------------------
1)StringBuffer sb=new StringBuffer();
2)StringBuffer sb1=new StringBuffer(int capacity);
3)StringBuffer sb2=new StringBUffer(String str);
class SBTest
{
public static void main(String args[])
{
StringBuffer sb=new StringBuffer();
[Link]([Link]());//default capacity is a 16
StringBuffer sb1=new StringBuffer(5);
[Link]([Link]());
StringBuffer sb2=new StringBuffer("digitinstitute");
[Link]([Link]());
}
}
-----------------------------------------------------------------------------
StringBuffer is a mutable:----
-----------------------------------
Once we are creating the STring object it is possible to the modification on
existing object it is called as a
mutability nature
class SBMutable
{
public static void main(String args[])
{
StringBuffer sb=new StringBuffer("Hyderabad");
[Link]("How are you?");
[Link](sb);
}
}
---------------------------------------------------------
StringBuilder:----
-------------------------
It is inroduce in jdk1.5 version
StringBuilder exactly same as StringBuffer except one imp difference
Every method present in the StringBuilder is not Synchronized means threads are not
required to wait so not thread safe
multiple threads are allow to operate on StringBuilder methods hence performance of
the application is increased.
Wrapper Classes:----
-----------------------
To repraents primitive data types as a Object form we required some classes those
classes are called as a Wrapper classes
[Link] package
byte-------->Byte
short------->Short
int--------->Integer
long-------->Long
float------->Float
double------>Double
boolean------>Boolean
char--------->Character
------------------------------------------------------
class SBTest
{
public static void main(String args[])
{
StringBuffer sb=new StringBuffer();
[Link]([Link]());//default capacity is a 16
StringBuffer sb1=new StringBuffer(5);
[Link]([Link]());
StringBuffer sb2=new StringBuffer("gammainnovations");
[Link]([Link]());
}
}
-------------------------------------
class SBMutable
{
public static void main(String args[])
{
StringBuilder sb=new StringBuilder("Hyderabad");
[Link]("How are you?");
[Link](sb);
}
}
---------------------------------------------------------------
Exception Handling:----
----------------------------
90 years--------->4am
1cr----->ATM
--->card insert---->wrong---->NullPointerException
Bank-------->software company----->Sun microsystem---->technical error------
>userfriendly information(endusers)
NullpointerException------>Hello boss your entered pin is wrong, plese enter
correct pin
Exception:-----
--------------------
--->An exeception is an a problem occured during execution time of the program
--->An exeception is a unwanted unexpected event that event distrubs the normal
flow of the execution called as a
exception.
Types of Exceptions:----
-------------------------------
As per sun micro systems standards the exceptions are divided into 3 types
1)Checked Exceptions
2)Unchecked Exceptions
3)Error
----------------------------------------
1)Checked Exceptions:----
----------------------------
The exceptions which are checked by the compiler at compilation time
1)ClassNotFoundException:----If the loadded class is not avialable
2)IllegalAccessException:---Access to a class is denied
3)InstantiationException:---Attempt to create an object of a abstract class and
interface
4)NoSuchFieldException:---A requested field does not exist
5)NoSuchMethodExcetion:---If the requested method does not exist
2)Unchecked Exception:-----
---------------------------------