SlideShare a Scribd company logo
1 of 11
CONTENT
Types of array
String and StringBuffer
Class
Method of StringBuffer
Class
Array
• Array is similar type of elements and share a common name.
• Syntax
datatype variblename [ ] = new type [size of array]
• Example
int a [ ] = new int [7]
•Types of array :
1) Single dimension array
2) Multi dimension array
Single dimension array
• Syntax
int a[ ] = new int [ 10 ]
• An array using one subscript to represent the list of element is called
Single dimension array.
Multi dimension array
• Syntax
int a [ ] = new int [3] [3]
row column
• In Java , multi dimension array is actually array of arrays.
Stringclass
• An obj of the string class represent a string of class.
• String class belong the java.lang package which does not require the input-output
statement.
• Like , other classes string has constructor and methods.
• Syntax :
String s = new String (“hello”);
System.out.println(s);
String s1 = new String (s);
String s = “hello world”;
System.out.println(s);
StringBufferclass
• The java.lang.StringBuffer class is a mutable sequence of characters.
• A String buffer is like a string , but can be modified.
• It contains some sequence of characters , but the length and content
of the sequence can be changed through certain method calls.
• They are safe for by multiple threads.
• Syntax
StringBuffer sb = new StringBuffer ();
DifferencebetweenStringandStringBuffer
BASIS FOR COMPARISON STRING STRINGBUFFER
Basic The length of the String object is
fixed.
The length of the StringBuffer can
be increased.
Modification String object is immutable. StringBuffer object is mutable.
Performance It is slower during concatenation. It is faster during concatenation.
Memory Consumes more memory. Consumes less memory.
Method of StringBuffer class
METHODS
Description
SetLength ( int size) It is used to set the length of string.
CharAt (int index) It returns the character at the specified index in a string.
SetcharAt (int index , char ch) It is used to set the specified character at the given
index. It replacing the old character at the given index.
append (String s) It is used to append the specified string with this String.
Insert (int index , String str) It is used to insert the specified String at the specified
position.
reverse( ) It is used to reverse the string.
replace (int startindex , int endindex ,String str) It is used to replace the string from specified startindex
and endindex.
getchars (int S , int E , char a[ ] , int
target)
Where , S = startindex
E = endindex
It is used for copying String characters to an array of
chars.
Ex :
StringBuffer sb = new StringBuffer (“Java Program”);
Char[ ] dst = new char[ ] {‘s’ , ‘t’ , ‘r’ , ‘i’ , ‘n’ , ‘g’ , ‘B’ ,
‘u’ , ‘f’ , ‘f’ , ‘e’ , ‘r’ };
Sb.getchars(5,12,dst,2);
System.out.println(dst); //stProgramer
ExampleofmethodStringBufferclass
• StringBuffer sb = new StringBuffer (“VIE”);
sb.SetLength (2); //VI
• char c = sb.charAt (1);
System.out.println(c); // V
• sb.SetcharAt ( 0 , ‘A’);
System.out.println(sb.toString()); //AIE
• String str = “college”;
sb.append(str);
System.out.println(sb.toString()); //VIE college
• sb.insert (1 , “kotambi”);
System.out.println(sb.toString()); //VkotambiIE
• sb.reverse ();
System.out.println(sb.toString()); //EIV
• StringBuffer sb = new StringBuffer (“hellobye”);
sb.replace(5,7,”hi”);
System.out.println(sb.toString()); // hellohibye
Java

More Related Content

What's hot (20)

Chap 7(array)
Chap 7(array)Chap 7(array)
Chap 7(array)
 
Arrays and Strings
Arrays and Strings Arrays and Strings
Arrays and Strings
 
String handling(string buffer class)
String handling(string buffer class)String handling(string buffer class)
String handling(string buffer class)
 
Java arrays
Java arraysJava arrays
Java arrays
 
Python :variable types
Python :variable typesPython :variable types
Python :variable types
 
ARRAY
ARRAYARRAY
ARRAY
 
Java Arrays
Java ArraysJava Arrays
Java Arrays
 
OOPs with java
OOPs with javaOOPs with java
OOPs with java
 
L14 string handling(string buffer class)
L14 string handling(string buffer class)L14 string handling(string buffer class)
L14 string handling(string buffer class)
 
Array in C# 3.5
Array in C# 3.5Array in C# 3.5
Array in C# 3.5
 
Data Structures in Python
Data Structures in PythonData Structures in Python
Data Structures in Python
 
C# Arrays
C# ArraysC# Arrays
C# Arrays
 
An Introduction to Programming in Java: Arrays
An Introduction to Programming in Java: ArraysAn Introduction to Programming in Java: Arrays
An Introduction to Programming in Java: Arrays
 
6 arrays injava
6 arrays injava6 arrays injava
6 arrays injava
 
String Handling
String HandlingString Handling
String Handling
 
C++ Arrays
C++ ArraysC++ Arrays
C++ Arrays
 
Java chapter 6 - Arrays -syntax and use
Java chapter 6 - Arrays -syntax and useJava chapter 6 - Arrays -syntax and use
Java chapter 6 - Arrays -syntax and use
 
String in python lecture (3)
String in python lecture (3)String in python lecture (3)
String in python lecture (3)
 
Array
ArrayArray
Array
 
Arrays Basics
Arrays BasicsArrays Basics
Arrays Basics
 

Similar to Java

Strings Arrays
Strings ArraysStrings Arrays
Strings Arraysphanleson
 
In the given example only one object will be created. Firstly JVM will not fi...
In the given example only one object will be created. Firstly JVM will not fi...In the given example only one object will be created. Firstly JVM will not fi...
In the given example only one object will be created. Firstly JVM will not fi...Indu32
 
javastringexample problems using string class
javastringexample problems using string classjavastringexample problems using string class
javastringexample problems using string classfedcoordinator
 
Fileoperations.pptx
Fileoperations.pptxFileoperations.pptx
Fileoperations.pptxVeenaNaik23
 
Java string handling
Java string handlingJava string handling
Java string handlingSalman Khan
 
Chapter 9 - Characters and Strings
Chapter 9 - Characters and StringsChapter 9 - Characters and Strings
Chapter 9 - Characters and StringsEduardo Bergavera
 
Java căn bản - Chapter9
Java căn bản - Chapter9Java căn bản - Chapter9
Java căn bản - Chapter9Vince Vo
 
Strings In OOP(Object oriented programming)
Strings In OOP(Object oriented programming)Strings In OOP(Object oriented programming)
Strings In OOP(Object oriented programming)Danial Virk
 
String Handling, Inheritance, Packages and Interfaces
String Handling, Inheritance, Packages and InterfacesString Handling, Inheritance, Packages and Interfaces
String Handling, Inheritance, Packages and InterfacesPrabu U
 

Similar to Java (20)

Strings Arrays
Strings ArraysStrings Arrays
Strings Arrays
 
In the given example only one object will be created. Firstly JVM will not fi...
In the given example only one object will be created. Firstly JVM will not fi...In the given example only one object will be created. Firstly JVM will not fi...
In the given example only one object will be created. Firstly JVM will not fi...
 
Strings in Java
Strings in JavaStrings in Java
Strings in Java
 
javastringexample problems using string class
javastringexample problems using string classjavastringexample problems using string class
javastringexample problems using string class
 
Fileoperations.pptx
Fileoperations.pptxFileoperations.pptx
Fileoperations.pptx
 
Java string handling
Java string handlingJava string handling
Java string handling
 
Chapter 9 - Characters and Strings
Chapter 9 - Characters and StringsChapter 9 - Characters and Strings
Chapter 9 - Characters and Strings
 
Java căn bản - Chapter9
Java căn bản - Chapter9Java căn bản - Chapter9
Java căn bản - Chapter9
 
07slide
07slide07slide
07slide
 
String handling
String handlingString handling
String handling
 
package
packagepackage
package
 
StringBuffer.pptx
StringBuffer.pptxStringBuffer.pptx
StringBuffer.pptx
 
Strings In OOP(Object oriented programming)
Strings In OOP(Object oriented programming)Strings In OOP(Object oriented programming)
Strings In OOP(Object oriented programming)
 
ch06.ppt
ch06.pptch06.ppt
ch06.ppt
 
ch06.ppt
ch06.pptch06.ppt
ch06.ppt
 
ch06.ppt
ch06.pptch06.ppt
ch06.ppt
 
ch06.ppt
ch06.pptch06.ppt
ch06.ppt
 
array Details
array Detailsarray Details
array Details
 
String Handling, Inheritance, Packages and Interfaces
String Handling, Inheritance, Packages and InterfacesString Handling, Inheritance, Packages and Interfaces
String Handling, Inheritance, Packages and Interfaces
 
Arrays
ArraysArrays
Arrays
 

More from JahnaviBhagat

More from JahnaviBhagat (10)

Se
SeSe
Se
 
A.java
A.javaA.java
A.java
 
Mpi
MpiMpi
Mpi
 
System Programming
System ProgrammingSystem Programming
System Programming
 
Indeterminate forms
Indeterminate formsIndeterminate forms
Indeterminate forms
 
Contributor personality development
Contributor personality development Contributor personality development
Contributor personality development
 
Electrical engineering
Electrical engineeringElectrical engineering
Electrical engineering
 
computer organization
computer organizationcomputer organization
computer organization
 
Computer Network
Computer NetworkComputer Network
Computer Network
 
Dbms
DbmsDbms
Dbms
 

Recently uploaded

MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLSMANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLSSIVASHANKAR N
 
UNIT-II FMM-Flow Through Circular Conduits
UNIT-II FMM-Flow Through Circular ConduitsUNIT-II FMM-Flow Through Circular Conduits
UNIT-II FMM-Flow Through Circular Conduitsrknatarajan
 
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...roncy bisnoi
 
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service NashikCall Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service NashikCall Girls in Nagpur High Profile
 
Introduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxIntroduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxupamatechverse
 
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
Processing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxProcessing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxpranjaldaimarysona
 
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Dr.Costas Sachpazis
 
Introduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxIntroduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxupamatechverse
 
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...Call Girls in Nagpur High Profile
 
Glass Ceramics: Processing and Properties
Glass Ceramics: Processing and PropertiesGlass Ceramics: Processing and Properties
Glass Ceramics: Processing and PropertiesPrabhanshu Chaturvedi
 
Online banking management system project.pdf
Online banking management system project.pdfOnline banking management system project.pdf
Online banking management system project.pdfKamal Acharya
 
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINEMANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINESIVASHANKAR N
 
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...ranjana rawat
 
University management System project report..pdf
University management System project report..pdfUniversity management System project report..pdf
University management System project report..pdfKamal Acharya
 
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Bookingdharasingh5698
 
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
Coefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxCoefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxAsutosh Ranjan
 
result management system report for college project
result management system report for college projectresult management system report for college project
result management system report for college projectTonystark477637
 

Recently uploaded (20)

MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLSMANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
 
UNIT-II FMM-Flow Through Circular Conduits
UNIT-II FMM-Flow Through Circular ConduitsUNIT-II FMM-Flow Through Circular Conduits
UNIT-II FMM-Flow Through Circular Conduits
 
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
 
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service NashikCall Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
 
Introduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxIntroduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptx
 
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
 
Processing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxProcessing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptx
 
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
 
Introduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxIntroduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptx
 
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
 
Glass Ceramics: Processing and Properties
Glass Ceramics: Processing and PropertiesGlass Ceramics: Processing and Properties
Glass Ceramics: Processing and Properties
 
Online banking management system project.pdf
Online banking management system project.pdfOnline banking management system project.pdf
Online banking management system project.pdf
 
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINEMANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
 
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
 
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
 
University management System project report..pdf
University management System project report..pdfUniversity management System project report..pdf
University management System project report..pdf
 
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
 
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
 
Coefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxCoefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptx
 
result management system report for college project
result management system report for college projectresult management system report for college project
result management system report for college project
 

Java

  • 1. CONTENT Types of array String and StringBuffer Class Method of StringBuffer Class
  • 2. Array • Array is similar type of elements and share a common name. • Syntax datatype variblename [ ] = new type [size of array] • Example int a [ ] = new int [7] •Types of array : 1) Single dimension array 2) Multi dimension array
  • 3. Single dimension array • Syntax int a[ ] = new int [ 10 ] • An array using one subscript to represent the list of element is called Single dimension array. Multi dimension array • Syntax int a [ ] = new int [3] [3] row column • In Java , multi dimension array is actually array of arrays.
  • 4. Stringclass • An obj of the string class represent a string of class. • String class belong the java.lang package which does not require the input-output statement. • Like , other classes string has constructor and methods. • Syntax : String s = new String (“hello”); System.out.println(s); String s1 = new String (s); String s = “hello world”; System.out.println(s);
  • 5. StringBufferclass • The java.lang.StringBuffer class is a mutable sequence of characters. • A String buffer is like a string , but can be modified. • It contains some sequence of characters , but the length and content of the sequence can be changed through certain method calls. • They are safe for by multiple threads. • Syntax StringBuffer sb = new StringBuffer ();
  • 6. DifferencebetweenStringandStringBuffer BASIS FOR COMPARISON STRING STRINGBUFFER Basic The length of the String object is fixed. The length of the StringBuffer can be increased. Modification String object is immutable. StringBuffer object is mutable. Performance It is slower during concatenation. It is faster during concatenation. Memory Consumes more memory. Consumes less memory.
  • 7. Method of StringBuffer class METHODS Description SetLength ( int size) It is used to set the length of string. CharAt (int index) It returns the character at the specified index in a string. SetcharAt (int index , char ch) It is used to set the specified character at the given index. It replacing the old character at the given index. append (String s) It is used to append the specified string with this String. Insert (int index , String str) It is used to insert the specified String at the specified position. reverse( ) It is used to reverse the string. replace (int startindex , int endindex ,String str) It is used to replace the string from specified startindex and endindex.
  • 8. getchars (int S , int E , char a[ ] , int target) Where , S = startindex E = endindex It is used for copying String characters to an array of chars. Ex : StringBuffer sb = new StringBuffer (“Java Program”); Char[ ] dst = new char[ ] {‘s’ , ‘t’ , ‘r’ , ‘i’ , ‘n’ , ‘g’ , ‘B’ , ‘u’ , ‘f’ , ‘f’ , ‘e’ , ‘r’ }; Sb.getchars(5,12,dst,2); System.out.println(dst); //stProgramer
  • 9. ExampleofmethodStringBufferclass • StringBuffer sb = new StringBuffer (“VIE”); sb.SetLength (2); //VI • char c = sb.charAt (1); System.out.println(c); // V • sb.SetcharAt ( 0 , ‘A’); System.out.println(sb.toString()); //AIE • String str = “college”; sb.append(str); System.out.println(sb.toString()); //VIE college • sb.insert (1 , “kotambi”); System.out.println(sb.toString()); //VkotambiIE
  • 10. • sb.reverse (); System.out.println(sb.toString()); //EIV • StringBuffer sb = new StringBuffer (“hellobye”); sb.replace(5,7,”hi”); System.out.println(sb.toString()); // hellohibye