x (Lec-25 or 30)Java SE(String Handling)
x (Lec-25 or 30)Java SE(String Handling)
(CORE JAVA)
LECTURE-30
Today’s Agenda
• String Handling.
1. String
2. StringBuffer
3. StringBuilder
• For Example,
String city=“Bhopal”;
System.out.println(city);
city=“Indore”;
System.out.println(city);
Though the output will change but the Objects won’t.
Constructors of String
Difference in Initialization:-
String s1=new String(“Sky”);
String s2=new String(“Sky”);
String s3=“Sky”;
String s4=“Sky”;
Constructors of String
String(char[ ],int1,int2):-
int1- Starting index
int2- Number of characters to be converted into String
char arr[ ]={‘H’, ‘e’, ‘l’, ‘l’, ‘o’};
String s=new String(arr,0,4);
System.out.println(s); Hell
• In java anything in “ ”(double quotes) is
considered to be a string to be precise a String
object.
• Example :- “Bhopal”.length(); 6
Methods of String class