This document discusses strings and string buffers in Java. It defines strings as sequences of characters that are class objects implemented using the String and StringBuffer classes. It provides examples of declaring, initializing, concatenating and using various methods like length(), charAt() etc. on strings. The document also introduces the StringBuffer class for mutable strings and lists some common StringBuffer functions.
This document discusses Java strings and provides information about:
1. What strings are in Java and how they are treated as objects of the String class. Strings are immutable.
2. Two ways to create String objects: using string literals or the new keyword.
3. Important string methods like concatenation, comparison, substring, and length; and string classes like StringBuffer and StringBuilder that allow mutability.
javastringexample problems using string classfedcoordinator
Java strings are sequences of characters that are treated as objects. The String class provides methods to create and manipulate strings. Strings are immutable, so the StringBuffer and StringBuilder classes provide mutable alternatives. Key string methods include concat(), equals(), substring(), length(), and indexOf(). The StringBuffer class is synchronized and thread-safe, while the StringBuilder class is non-synchronized and more efficient for single-threaded use.
The document discusses the StringBuffer class in Java. Some key points:
- StringBuffer is like String but mutable and growable, used for string concatenation.
- It has methods to append, insert, delete, and modify characters. As characters are added and removed, the StringBuffer will automatically increase capacity if needed.
- Common methods include append(), insert(), delete(), replace(), reverse(), and substring() to modify the character sequence within a StringBuffer.
In the given example only one object will be created. Firstly JVM will not fi...Indu32
In the given example only one object will be created. Firstly JVM will not find any string object with the value “Welcome” in the string constant pool, so it will create a new object. After that it will find the string with the value “Welcome” in the pool, it will not create a new object but will return the reference to the same instance. In this article, we will learn about Java Strings.
This document discusses the StringBuffer and StringBuilder classes in Java. It explains that StringBuffer can be used to create mutable strings, while StringBuilder is similar but non-synchronized. It outlines several key methods for each class, such as append(), insert(), reverse(), substring(), and describes how to construct and manipulate string objects in Java.
StringBuffer implements a mutable sequence of characters that can be modified unlike strings. It has methods to modify the character sequence such as append, insert, delete and replace. It can grow dynamically as characters are added and its methods are used by the compiler to implement string concatenation with the + operator.
StringBuffer implements a mutable sequence of characters that can be modified unlike strings. It has methods to modify the character sequence such as append, insert, delete and replace. It can grow dynamically as characters are added and its methods are used by the compiler to implement string concatenation with the + operator.
String Handling, Inheritance, Packages and InterfacesPrabu U
The presentation starts with string handling. Then the concepts of inheritance is detailed. Finally the concepts of packages and interfaces are detailed.
The document discusses various Java string concepts:
1. Java strings are immutable sequences of characters that are objects of the String class. The StringBuffer class can be used to modify strings.
2. Common string methods include length(), charAt(), compareTo(), concat(), and substring().
3. The StringBuffer class represents mutable strings and defines methods like append(), insert(), delete(), and replace() to modify the string content.
4. Enumerated types in Java can be defined using the enum keyword to represent a fixed set of constants, like the days of the week.
Wrapper classes allow primitive data types to be used as objects. Wrapper classes include Integer, Double, Boolean etc. Strings in Java are immutable - their values cannot be changed once created. StringBuffer and StringBuilder can be used to create mutable strings that can be modified. StringTokenizer can split a string into tokens based on a specified delimiter.
String is an object that represents a sequence of characters. The three main String classes in Java are String, StringBuffer, and StringTokenizer. String is immutable, while StringBuffer allows contents to be modified. Common string methods include length(), charAt(), substring(), indexOf(), and equals(). The StringBuffer class is similar to String but more flexible as it allows adding, inserting and appending new contents.
Java string , string buffer and wrapper classSimoniShah6
The document discusses Java strings and wrapper classes. It provides examples of creating and manipulating strings using the String, StringBuffer, and StringBuilder classes. It also discusses the eight primitive wrapper classes in Java and examples converting between primitive types and their corresponding wrapper classes.
The StringBuffer class represents mutable sequences of characters. It is similar to strings but allows modifications by providing methods like append(), insert(), delete(), and replace(). StringBuffer has a default capacity of 16 characters that is increased automatically when more space is needed to store character sequences. It is used by the compiler to implement string concatenation with the + operator.
This document discusses arrays and StringBuffer class in Java. It defines single and multi-dimensional arrays and provides examples. It also explains the difference between String and StringBuffer classes and lists common methods of StringBuffer class like append(), insert(), reverse() etc. Examples are given to demonstrate the usage of these StringBuffer methods.
String objects in Java are immutable and stored in a string pool to improve performance. The StringBuffer class can be used to create mutable strings that can be modified after creation. It provides methods like append(), insert(), replace(), and delete() to modify the string content. The ensureCapacity() method on StringBuffer is used to reserve enough memory to reduce reallocation as the string is modified.
This document outlines the topics of string handling, multithreaded programming, and Java database connectivity in Java. For string handling, it discusses the String, StringBuffer, and StringBuilder classes and their properties like mutability. It also covers string constructors and methods for extracting, comparing, and modifying strings. For multithreaded programming, it lists the need for multiple threads and concepts like thread states, priorities, and inter-thread communication. For Java database connectivity, it mentions the JDBC architecture and tasks like establishing connections, processing result sets, and transactions.
The document discusses strings and StringBuffers in Java. Strings are immutable sequences of characters represented by the String class. StringBuffers allow modifying character sequences and are represented by the StringBuffer class. The summary provides an overview of common string and StringBuffer operations like concatenation, extraction, comparison, and modification.
This document discusses string handling, multithreaded programming, and Java database connectivity in Java. It covers:
- String classes like String, StringBuffer, StringBuilder and the CharSequence interface. It describes string construction and properties.
- Methods for extracting, comparing, modifying and searching strings. This includes charAt(), equals(), replace(), substring() etc.
- Multithreaded programming concepts like threads, states, priorities and communication.
- JDBC architecture and components. It discusses establishing database connections, result sets, batch processing and transactions.
The document provides examples to explain string handling methods and multithreaded programming concepts in Java. It aims to introduce the topics of string handling, mult
Strings In OOP(Object oriented programming)Danial Virk
The document discusses strings and string handling in Java. It covers the String and StringBuffer classes, basic string methods like length(), substring(), indexOf(), and replace(). It also discusses parsing strings with StringTokenizer and the differences between StringBuffer and String in terms of mutability and capacity. StringBuffer allows growing the string size while String is immutable.
This document discusses string handling in Java. It covers key topics like:
- Strings are immutable objects in Java
- The String, StringBuffer, and StringBuilder classes can be used to manipulate strings
- Common string methods like length(), concat(), indexOf(), and replace()
- Strings can be compared using equals(), startsWith(), and compareTo()
- Immutability avoids security issues when strings are passed as parameters
The StringBuilder class in Java is used to create mutable strings. It is similar to the StringBuffer class but is non-synchronized. Some key methods of StringBuilder include append() to add to the string, insert() to insert into the string, replace() to replace part of the string, and delete() to remove part of the string. StringBuilder also allows getting and setting the capacity, length, and characters of the string.
This document discusses string handling in Java. Some key points:
- Strings are immutable sequences of characters represented by the String class. StringBuffer allows mutable strings.
- Constructors can initialize strings from arrays of characters or other strings. Methods like length(), charAt(), and compareTo() operate on strings.
- Strings can be concatenated, searched, extracted, modified, and converted between cases. StringBuffer supports mutable operations like insertion and deletion.
The document discusses the String class in Java. It states that a String represents a sequence of characters and belongs to the java.lang package. Character sequences can be represented using character arrays, but character arrays do not support the full range of string operations. In Java, strings are class objects implemented using the String and StringBuffer classes. Strings are immutable while StringBuffers are mutable and support modifying string contents.
Artificial intelligence Presented by JM.jmansha170
AI (Artificial Intelligence) :
"AI is the ability of machines to mimic human intelligence, such as learning, decision-making, and problem-solving."
Important Points about AI:
1. Learning – AI can learn from data (Machine Learning).
2. Automation – It helps automate repetitive tasks.
3. Decision Making – AI can analyze and make decisions faster than humans.
4. Natural Language Processing (NLP) – AI can understand and generate human language.
5. Vision & Recognition – AI can recognize images, faces, and patterns.
6. Used In – Healthcare, finance, robotics, education, and more.
Owner By:
Name : Junaid Mansha
Work : Web Developer and Graphics Designer
Contact us : +92 322 2291672
Email : [email protected]
Energy Balances Of Oecd Countries 2011 Iea Statistics 1st Edition Oecdrazelitouali
Energy Balances Of Oecd Countries 2011 Iea Statistics 1st Edition Oecd
Energy Balances Of Oecd Countries 2011 Iea Statistics 1st Edition Oecd
Energy Balances Of Oecd Countries 2011 Iea Statistics 1st Edition Oecd
More Related Content
Similar to STRING CLASS AND STRING BUFFER CLASS CONCEPTS IN JAVA (20)
String Handling, Inheritance, Packages and InterfacesPrabu U
The presentation starts with string handling. Then the concepts of inheritance is detailed. Finally the concepts of packages and interfaces are detailed.
The document discusses various Java string concepts:
1. Java strings are immutable sequences of characters that are objects of the String class. The StringBuffer class can be used to modify strings.
2. Common string methods include length(), charAt(), compareTo(), concat(), and substring().
3. The StringBuffer class represents mutable strings and defines methods like append(), insert(), delete(), and replace() to modify the string content.
4. Enumerated types in Java can be defined using the enum keyword to represent a fixed set of constants, like the days of the week.
Wrapper classes allow primitive data types to be used as objects. Wrapper classes include Integer, Double, Boolean etc. Strings in Java are immutable - their values cannot be changed once created. StringBuffer and StringBuilder can be used to create mutable strings that can be modified. StringTokenizer can split a string into tokens based on a specified delimiter.
String is an object that represents a sequence of characters. The three main String classes in Java are String, StringBuffer, and StringTokenizer. String is immutable, while StringBuffer allows contents to be modified. Common string methods include length(), charAt(), substring(), indexOf(), and equals(). The StringBuffer class is similar to String but more flexible as it allows adding, inserting and appending new contents.
Java string , string buffer and wrapper classSimoniShah6
The document discusses Java strings and wrapper classes. It provides examples of creating and manipulating strings using the String, StringBuffer, and StringBuilder classes. It also discusses the eight primitive wrapper classes in Java and examples converting between primitive types and their corresponding wrapper classes.
The StringBuffer class represents mutable sequences of characters. It is similar to strings but allows modifications by providing methods like append(), insert(), delete(), and replace(). StringBuffer has a default capacity of 16 characters that is increased automatically when more space is needed to store character sequences. It is used by the compiler to implement string concatenation with the + operator.
This document discusses arrays and StringBuffer class in Java. It defines single and multi-dimensional arrays and provides examples. It also explains the difference between String and StringBuffer classes and lists common methods of StringBuffer class like append(), insert(), reverse() etc. Examples are given to demonstrate the usage of these StringBuffer methods.
String objects in Java are immutable and stored in a string pool to improve performance. The StringBuffer class can be used to create mutable strings that can be modified after creation. It provides methods like append(), insert(), replace(), and delete() to modify the string content. The ensureCapacity() method on StringBuffer is used to reserve enough memory to reduce reallocation as the string is modified.
This document outlines the topics of string handling, multithreaded programming, and Java database connectivity in Java. For string handling, it discusses the String, StringBuffer, and StringBuilder classes and their properties like mutability. It also covers string constructors and methods for extracting, comparing, and modifying strings. For multithreaded programming, it lists the need for multiple threads and concepts like thread states, priorities, and inter-thread communication. For Java database connectivity, it mentions the JDBC architecture and tasks like establishing connections, processing result sets, and transactions.
The document discusses strings and StringBuffers in Java. Strings are immutable sequences of characters represented by the String class. StringBuffers allow modifying character sequences and are represented by the StringBuffer class. The summary provides an overview of common string and StringBuffer operations like concatenation, extraction, comparison, and modification.
This document discusses string handling, multithreaded programming, and Java database connectivity in Java. It covers:
- String classes like String, StringBuffer, StringBuilder and the CharSequence interface. It describes string construction and properties.
- Methods for extracting, comparing, modifying and searching strings. This includes charAt(), equals(), replace(), substring() etc.
- Multithreaded programming concepts like threads, states, priorities and communication.
- JDBC architecture and components. It discusses establishing database connections, result sets, batch processing and transactions.
The document provides examples to explain string handling methods and multithreaded programming concepts in Java. It aims to introduce the topics of string handling, mult
Strings In OOP(Object oriented programming)Danial Virk
The document discusses strings and string handling in Java. It covers the String and StringBuffer classes, basic string methods like length(), substring(), indexOf(), and replace(). It also discusses parsing strings with StringTokenizer and the differences between StringBuffer and String in terms of mutability and capacity. StringBuffer allows growing the string size while String is immutable.
This document discusses string handling in Java. It covers key topics like:
- Strings are immutable objects in Java
- The String, StringBuffer, and StringBuilder classes can be used to manipulate strings
- Common string methods like length(), concat(), indexOf(), and replace()
- Strings can be compared using equals(), startsWith(), and compareTo()
- Immutability avoids security issues when strings are passed as parameters
The StringBuilder class in Java is used to create mutable strings. It is similar to the StringBuffer class but is non-synchronized. Some key methods of StringBuilder include append() to add to the string, insert() to insert into the string, replace() to replace part of the string, and delete() to remove part of the string. StringBuilder also allows getting and setting the capacity, length, and characters of the string.
This document discusses string handling in Java. Some key points:
- Strings are immutable sequences of characters represented by the String class. StringBuffer allows mutable strings.
- Constructors can initialize strings from arrays of characters or other strings. Methods like length(), charAt(), and compareTo() operate on strings.
- Strings can be concatenated, searched, extracted, modified, and converted between cases. StringBuffer supports mutable operations like insertion and deletion.
The document discusses the String class in Java. It states that a String represents a sequence of characters and belongs to the java.lang package. Character sequences can be represented using character arrays, but character arrays do not support the full range of string operations. In Java, strings are class objects implemented using the String and StringBuffer classes. Strings are immutable while StringBuffers are mutable and support modifying string contents.
Artificial intelligence Presented by JM.jmansha170
AI (Artificial Intelligence) :
"AI is the ability of machines to mimic human intelligence, such as learning, decision-making, and problem-solving."
Important Points about AI:
1. Learning – AI can learn from data (Machine Learning).
2. Automation – It helps automate repetitive tasks.
3. Decision Making – AI can analyze and make decisions faster than humans.
4. Natural Language Processing (NLP) – AI can understand and generate human language.
5. Vision & Recognition – AI can recognize images, faces, and patterns.
6. Used In – Healthcare, finance, robotics, education, and more.
Owner By:
Name : Junaid Mansha
Work : Web Developer and Graphics Designer
Contact us : +92 322 2291672
Email : [email protected]
Energy Balances Of Oecd Countries 2011 Iea Statistics 1st Edition Oecdrazelitouali
Energy Balances Of Oecd Countries 2011 Iea Statistics 1st Edition Oecd
Energy Balances Of Oecd Countries 2011 Iea Statistics 1st Edition Oecd
Energy Balances Of Oecd Countries 2011 Iea Statistics 1st Edition Oecd
Different pricelists for different shops in odoo Point of Sale in Odoo 17Celine George
Price lists are a useful tool for managing the costs of your goods and services. This can assist you in working with other businesses effectively and maximizing your revenues. Additionally, you can provide your customers discounts by using price lists.
THERAPEUTIC COMMUNICATION included definition, characteristics, nurse patient...parmarjuli1412
The document provides an overview of therapeutic communication, emphasizing its importance in nursing to address patient needs and establish effective relationships. THERAPEUTIC COMMUNICATION included some topics like introduction of COMMUNICATION, definition, types, process of communication, definition therapeutic communication, goal, techniques of therapeutic communication, non-therapeutic communication, few ways to improved therapeutic communication, characteristics of therapeutic communication, barrier of THERAPEUTIC RELATIONSHIP, introduction of interpersonal relationship, types of IPR, elements/ dynamics of IPR, introduction of therapeutic nurse patient relationship, definition, purpose, elements/characteristics , and phases of therapeutic communication, definition of Johari window, uses, what actually model represent and its areas, THERAPEUTIC IMPASSES and its management in 5th semester Bsc. nursing and 2nd GNM students
Parenting Teens: Supporting Trust, resilience and independencePooky Knightsmith
For more information about my speaking and training work, visit: https://www.pookyknightsmith.com/speaking/
SESSION OVERVIEW:
Parenting Teens: Supporting Trust, Resilience & Independence
The teenage years bring new challenges—for teens and for you. In this practical session, we’ll explore how to support your teen through emotional ups and downs, growing independence, and the pressures of school and social life.
You’ll gain insights into the teenage brain and why boundary-pushing is part of healthy development, along with tools to keep communication open, build trust, and support emotional resilience. Expect honest ideas, relatable examples, and space to connect with other parents.
By the end of this session, you will:
• Understand how teenage brain development affects behaviour and emotions
• Learn ways to keep communication open and supportive
• Explore tools to help your teen manage stress and bounce back from setbacks
• Reflect on how to encourage independence while staying connected
• Discover simple strategies to support emotional wellbeing
• Share experiences and ideas with other parents
This presentation was provided by Jennifer Gibson of Dryad, during the first session of our 2025 NISO training series "Secrets to Changing Behavior in Scholarly Communications." Session One was held June 5, 2025.
How to Manage & Create a New Department in Odoo 18 EmployeeCeline George
In Odoo 18's Employee module, organizing your workforce into departments enhances management and reporting efficiency. Departments are a crucial organizational unit within the Employee module.
Completed Sunday 6/8. For Weekend 6/14 & 15th. (Fathers Day Weekend US.) These workshops are also timeless for future students TY. No admissions needed.
A 9th FREE WORKSHOP
Reiki - Yoga
“Intuition-II, The Chakras”
Your Attendance is valued.
We hit over 5k views for Spring Workshops and Updates-TY.
Thank you for attending our workshops.
If you are new, do welcome.
Grad Students: I am planning a Reiki-Yoga Master Course (As a package). I’m Fusing both together.
This will include the foundation of each practice. Our Free Workshops can be used with any Reiki Yoga training package. Traditional Reiki does host rules and ethics. Its silent and within the JP Culture/Area/Training/Word of Mouth. It allows remote healing but there’s limits As practitioners and masters, we are not allowed to share certain secrets/tools. Some content is designed only for “Masters”. Some yoga are similar like the Kriya Yoga-Church (Vowed Lessons). We will review both Reiki and Yoga (Master tools) in the Course upcoming.
S9/This Week’s Focus:
* A continuation of Intuition-2 Development. We will review the Chakra System - Our temple. A misguided, misused situation lol. This will also serve Attunement later.
Thx for tuning in. Your time investment is valued. I do select topics related to our timeline and community. For those seeking upgrades or Reiki Levels. Stay tuned for our June packages. It’s for self employed/Practitioners/Coaches…
Review & Topics:
* Reiki Is Japanese Energy Healing used Globally.
* Yoga is over 5k years old from India. It hosts many styles, teacher versions, and it’s Mainstream now vs decades ago.
* Anything of the Holistic, Wellness Department can be fused together. My origins are Alternative, Complementary Medicine. In short, I call this ND. I am also a metaphysician. I learnt during the 90s New Age Era. I forget we just hit another wavy. It’s GenZ word of Mouth, their New Age Era. WHOA, History Repeats lol. We are fusing together.
* So, most of you have experienced your Spiritual Awakening. However; The journey wont be perfect. There will be some roller coaster events. The perks are: We are in a faster Spiritual Zone than the 90s. There’s more support and information available.
(See Presentation for all sections, THX AGAIN.)
How to Manage Maintenance Request in Odoo 18Celine George
Efficient maintenance management is crucial for keeping equipment and work centers running smoothly in any business. Odoo 18 provides a Maintenance module that helps track, schedule, and manage maintenance requests efficiently.
How to Configure Vendor Management in Lunch App of Odoo 18Celine George
The Vendor management in the Lunch app of Odoo 18 is the central hub for managing all aspects of the restaurants or caterers that provide food for your employees.
HOW YOU DOIN'?
Cool, cool, cool...
Because that's what she said after THE QUIZ CLUB OF PSGCAS' TV SHOW quiz.
Grab your popcorn and be seated.
QM: THARUN S A
BCom Accounting and Finance (2023-26)
THE QUIZ CLUB OF PSGCAS.
How to Manage Upselling of Subscriptions in Odoo 18Celine George
Subscriptions in Odoo 18 are designed to auto-renew indefinitely, ensuring continuous service for customers. However, businesses often need flexibility to adjust pricing or quantities based on evolving customer needs.
Slides from a Capitol Technology University presentation covering doctoral programs offered by the university. All programs are online, and regionally accredited. The presentation covers degree program details, tuition, financial aid and the application process.
Exploring Ocean Floor Features for Middle SchoolMarie
This 16 slide science reader is all about ocean floor features. It was made to use with middle school students.
You can download the PDF at thehomeschooldaily.com
Thanks! Marie
*Order Hemiptera:*
Hemiptera, commonly known as true bugs, is a large and diverse order of insects that includes cicadas, aphids, leafhoppers, and shield bugs. Characterized by their piercing-sucking mouthparts, Hemiptera feed on plant sap, other insects, or small animals. Many species are significant pests, while others are beneficial predators.
*Order Neuroptera:*
Neuroptera, also known as net-winged insects, is an order of insects that includes lacewings, antlions, and owlflies. Characterized by their delicate, net-like wing venation and large, often prominent eyes, Neuroptera are predators that feed on other insects, playing an important role in biological control. Many species have aquatic larvae, adding to their ecological diversity.
2. STRINGS
Strings represent a sequence of characters.
The easiest way to represent a sequence of characters in
JAVA is by using a character array.
char Array[ ] = new char [5]; Character arrays are
not good enough to
support the range of
operations we want to
perform on strings.
In JAVA strings are class objects and implemented
using two classes:-
String
StringBuffer.
In JAVA strings are not a character array and is not
NULL terminated.
3. • Normally, objects in Java are created with the new keyword.
OR
• However, String objects can be created "implicitly":
DECLARING & INITIALISING
String name;
name = new String("Craig");
String name;
name = "Craig";
String name= new String("Craig");
4. String objects are handled specially by the compiler.
String is the only class which has "implicit"
instantiation.
The String class is defined in the java.lang package.
Strings are immutable.
The value of a String object can never be changed.
For mutable Strings, use the StringBuffer class.
The String Class
5. DYNAMIC INITIALIZATION OF
STRINGS
BufferedReader br = new
BufferedReader(new
InputStreamReader(System.in));
String city = br.readLine();
Scanner sc=new Scanner(System.in);
String state=sc.nextLine();
String state1=sc.next();
Give throws
IOException
beside
function
name
6. STRING CONCATENATION
JAVA string can be
concatenated using + operator.
String name="Ankita";
String surname="Karia";
System.out.println(name
+"
"+surname);
STRING Arrays
• An array of strings can also be created
String cities [ ] = new String[5];
7. String Methods
The String class contains many useful methods for
string- processing applications.
◦ A String method is called by writing a String object, a dot, the name
of the method, and a pair of parentheses to enclose any arguments
◦ If a String method returns a value, then it can be placed anywhere that
a value of its type can be used
String greeting = "Hello";
int count = greeting.length();
System.out.println("Length is " + greeting.length());
◦ Always count from zero when referring to the position or index of
a character in a string
String method
17. STRING
BUFFER
CLAS
S
STRINGBUFFER class creates strings flexible length that
can be modified in terms of both length and content.
STRINGBUFFER may have characters and substrings
inserted in the middle or appended to the end.
STRINGBUFFER automatically grows to make room for
such additions
Actually STRINGBUFFER has more
characters pre allocated than are actually
needed, to allow room for growth
18. STRING BUFFER CONSTRUCTORS
String Buffer():- Reserves room fro 16 characters
without reallocation
StringBuffer(int size):- Accepts an integer argunent
that explicilty sets the size of the buffer
StringBuffer(String str):- Accepts STRING argument
that sets the initial contents of the STRINGBUFFER and
allocated room for 16 additional characters.
19. STRING BUFFER
FUNCTIONS
length():-Returns the current length of the string.
capacity():- Returns the total allocated capacity.
void ensureCapacity():- Preallocates room for a certain
number of characters.
void setLength(int len):- Sets the length of the string
s1
to len.
If len<s1.length(), s1 is truncated.
If len>s1.length(), zeros are added to s1.
charAt(int where):- Extracts value of a single
character.
setCharAt(int where, char ch):- Sets the value of
21. STRING BUFFER
FUNCTIONS
append(s2):- Appends string s2 to s1 at the end.
insert(n,s2 ):- Inserts the string s2 at the position n of the
string s1
reverse():- Returns the reversed object on when it is
called.
delete(int n1,int n2):- Deletes a sequence of characters
from the invoking object.
n1
n2
deleteCharAt(int loc):- Deletes the character at the index
specified by loc.
Specifies index of first character to remove
Specifies index one past the lastcharacter to
remove
22. STRING BUFFER
FUNCTIONS
replace(int n1,int n2,String s1):- Replaces one set of
characters with another set.
substring(int startIndex):- Returns the substring that starts
at starts at startIndex and runs to the end.
substring(int startIndex, int endIndex):- Returns the
substring that starts at starts at startIndex and runs to the
endIndex-1
23. Difference between String and StringBuffer
No. String StringBuffer
1) String class is immutable. StringBuffer class is mutable.
2) String is slow and consumes
more memory when you
concat too many strings
because every time it
creates new instance.
StringBuffer is fast and
consumes less memory when
you cancat strings.
3) String class overrides the
equals() method of Object
class. So you can compare
the contents of two strings
by equals() method.
StringBuffer class doesn't
override the equals() method of
Object class.