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.
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.
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.
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.
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.
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.
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.
The document discusses the String class in Java. Some key points:
- Strings are immutable sequences of characters that are objects of type String
- The StringBuffer class can be used to modify strings, as it allows changes to the original string
- Common string methods include length(), charAt(), equals(), concat(), and substring()
- Autoboxing and unboxing allow automatic conversion between primitive types and their corresponding wrapper classes like Integer
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.
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.
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 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 document discusses Strings in Java. Some key points:
- A String represents a sequence of characters. The String class is used to create string objects which can exist in the string pool or heap.
- Char arrays are preferable over Strings for passwords due to security reasons. Strings can be manipulated more easily.
- The String class has many useful methods like length(), charAt(), indexOf(), replace(), toLowerCase(), substring() etc to work with and manipulate string values.
- StringBuffer is used to create mutable string objects that can be modified after creation using methods like append(), insert(), delete() etc. It is preferable over String for performance reasons while manipulating strings.
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.
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 and string processing. It covers that strings are immutable sequences of characters, how they are created and stored, and the differences between using the String, StringBuffer, and StringBuilder classes. It also summarizes common string methods and how to compare strings using the == operator, equals() method, and compareTo() method.
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 document summarizes key concepts about Strings in Java including:
1. Strings can be created using double quotes or by converting a character array to a String.
2. The length() method returns the number of characters in a String.
3. Strings can be concatenated using the + operator or concat() method.
4. The format() method can be used to create formatted String outputs.
5. Common String methods include charAt(), compareTo(), indexOf(), and length().
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.
The document provides an overview of Strings and StringBuilders in Java. It discusses Strings as immutable objects and how StringBuilders can be more efficient for modifying strings. It also covers common String and StringBuilder methods, when to use each, and exceptions in Java using try/catch blocks.
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 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.
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.
The document discusses the String class in Java. Some key points:
- Strings are immutable sequences of characters that are objects of type String
- The StringBuffer class can be used to modify strings, as it allows changes to the original string
- Common string methods include length(), charAt(), equals(), concat(), and substring()
- Autoboxing and unboxing allow automatic conversion between primitive types and their corresponding wrapper classes like Integer
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.
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.
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 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 document discusses Strings in Java. Some key points:
- A String represents a sequence of characters. The String class is used to create string objects which can exist in the string pool or heap.
- Char arrays are preferable over Strings for passwords due to security reasons. Strings can be manipulated more easily.
- The String class has many useful methods like length(), charAt(), indexOf(), replace(), toLowerCase(), substring() etc to work with and manipulate string values.
- StringBuffer is used to create mutable string objects that can be modified after creation using methods like append(), insert(), delete() etc. It is preferable over String for performance reasons while manipulating strings.
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.
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 and string processing. It covers that strings are immutable sequences of characters, how they are created and stored, and the differences between using the String, StringBuffer, and StringBuilder classes. It also summarizes common string methods and how to compare strings using the == operator, equals() method, and compareTo() method.
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 document summarizes key concepts about Strings in Java including:
1. Strings can be created using double quotes or by converting a character array to a String.
2. The length() method returns the number of characters in a String.
3. Strings can be concatenated using the + operator or concat() method.
4. The format() method can be used to create formatted String outputs.
5. Common String methods include charAt(), compareTo(), indexOf(), and length().
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.
The document provides an overview of Strings and StringBuilders in Java. It discusses Strings as immutable objects and how StringBuilders can be more efficient for modifying strings. It also covers common String and StringBuilder methods, when to use each, and exceptions in Java using try/catch blocks.
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.
- HTML5 is the newest version of HTML that began development in 2004 and was officially published in 2012.
- It incorporates features from prior HTML versions and adds new elements and features like built-in audio/video, canvas drawing, and offline web apps.
- HTML5 simplifies elements like DOCTYPE and <html> and removes unnecessary code like XML namespaces.
This document provides an introduction to the Python programming language. It discusses that Python was created in 1991, is an interpreted language useful for scripting, and is used by many companies and organizations. It also gives instructions on installing Python on Windows, Mac OS X, and Linux systems. Finally, it demonstrates some basic Python concepts like print statements, comments, functions, and whitespace significance through simple code examples.
This document discusses Java interfaces. It describes how interfaces define abstract methods that implementing classes must provide. Interfaces can contain constant variables and default methods. Classes can inherit methods from extended interfaces and must implement inherited abstract methods. Default methods provide an implementation within an interface that classes can optionally override. Static methods are defined with the static keyword and are not inherited by implementing classes. Polymorphism allows objects to be accessed using superclass or interface references.
This document discusses JavaScript functions. It explains that functions are first-class objects that can be stored in variables, passed as arguments, and returned from other functions. It provides examples of defining, calling, and returning values from functions. It also covers optional parameters, anonymous functions, higher-order functions, and functions as methods.
This document provides an overview of interfaces in Java. It discusses that interfaces define abstract methods that implementing classes must provide, interfaces can contain constant variables and default methods, and interfaces cannot be instantiated directly. It also covers interface inheritance, default methods introduced in Java 8, static methods in interfaces, and polymorphism through interfaces.
This document summarizes a session on the Java technology. It introduces key concepts like the Java Runtime Environment (JRE) and Java Virtual Machine (JVM). The JRE loads and executes Java classes, verifies code, and performs garbage collection. The JVM interprets Java bytecode and defines instruction sets, registers and memory areas. The document provides examples of a simple Java application and how to compile and run Java code, as well as examples of common compile-time and runtime errors.
This document provides an overview of the Java programming language. It discusses Java's key features such as being robust, multithreaded, architecture-neutral, interpreted, high-performance, distributed, and dynamic. Additional features added in later Java releases include Java Beans, serialization, remote method invocation, database connectivity, and more. Since its inception, Java usage has spread across hardware development, standalone applications, client-server applications, distributed applications, and enterprise applications, establishing Java as a full-fledged technology.
Java is a set of computer software and specifications that provides a system for developing application software and deploying it across multiple platforms. It is widely used to develop networked applications, embedded systems, mobile applications, games, web content and enterprise software. With millions of developers worldwide, Java enables efficient development and use of exciting applications.
Form-based login in Spring Security is configured using the <form-login> element. The action URL and input field names can be customized, and a custom login page can be specified using the login-page attribute. On login error, users are redirected to the URL configured in the authentication-failure-url attribute, and the error message is available in the SPRING_SECURITY_LAST_EXCEPTION session attribute.
This presentation was provided by Nicole 'Nici" Pfeiffer of the Center for Open Science (COS), 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.
Human Anatomy and Physiology II Unit 3 B pharm Sem 2
Respiratory system
Anatomy of respiratory system with special reference to anatomy
of lungs, mechanism of respiration, regulation of respiration
Lung Volumes and capacities transport of respiratory gases,
artificial respiration, and resuscitation methods
Urinary system
Anatomy of urinary tract with special reference to anatomy of
kidney and nephrons, functions of kidney and urinary tract,
physiology of urine formation, micturition reflex and role of
kidneys in acid base balance, role of RAS in kidney and
disorders of kidney
Unit- 4 Biostatistics & Research Methodology.pdfKRUTIKA CHANNE
Blocking and confounding (when a third variable, or confounder, influences both the exposure and the outcome) system for Two-level factorials (a type of experimental design where each factor (independent variable) is investigated at only two levels, typically denoted as "high" and "low" or "+1" and "-1")
Regression modeling (statistical model that estimates the relationship between one dependent variable and one or more independent variables using a line): Hypothesis testing in Simple and Multiple regression models
Introduction to Practical components of Industrial and Clinical Trials Problems: Statistical Analysis Using Excel, SPSS, MINITAB®️, DESIGN OF EXPERIMENTS, R - Online Statistical Software to Industrial and Clinical trial approach
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.
Trends Spotting Strategic foresight for tomorrow’s education systems - Debora...EduSkills OECD
Deborah Nusche, Senior Analyst, OECD presents at the OECD webinar 'Trends Spotting: Strategic foresight for tomorrow’s education systems' on 5 June 2025. You can check out the webinar on the website https://oecdedutoday.com/webinars/ Other speakers included: Deborah Nusche, Senior Analyst, OECD
Sophie Howe, Future Governance Adviser at the School of International Futures, first Future Generations Commissioner for Wales (2016-2023)
Davina Marie, Interdisciplinary Lead, Queens College London
Thomas Jørgensen, Director for Policy Coordination and Foresight at European University Association
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.
Ray Dalio How Countries go Broke the Big CycleDadang Solihin
A complete and practical understanding of the Big Debt Cycle. A much more practical understanding of how supply and demand really work compared to the conventional economic thinking. A complete and practical understanding of the Overall Big Cycle, which is driven by the Big Debt Cycle and the other major cycles, including the big political cycle within countries that changes political orders and the big geopolitical cycle that changes world orders.
THE QUIZ CLUB OF PSGCAS BRINGS T0 YOU A FUN-FILLED, SEAT EDGE BUSINESS QUIZ
DIVE INTO THE PRELIMS OF BIZCOM 2024
QM: GOWTHAM S
BCom (2022-25)
THE QUIZ CLUB OF PSGCAS
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.
Analysis of Quantitative Data Parametric and non-parametric tests.pptxShrutidhara2
This presentation covers the following points--
Parametric Tests
• Testing the Significance of the Difference between Means
• Analysis of Variance (ANOVA) - One way and Two way
• Analysis of Co-variance (One-way)
Non-Parametric Tests:
• Chi-Square test
• Sign test
• Median test
• Sum of Rank test
• Mann-Whitney U-test
Moreover, it includes a comparison of parametric and non-parametric tests, a comparison of one-way ANOVA, two-way ANOVA, and one-way ANCOVA.
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
Adam Grant: Transforming Work Culture Through Organizational PsychologyPrachi Shah
This presentation explores the groundbreaking work of Adam Grant, renowned organizational psychologist and bestselling author. It highlights his key theories on giving, motivation, leadership, and workplace dynamics that have revolutionized how organizations think about productivity, collaboration, and employee well-being. Ideal for students, HR professionals, and leadership enthusiasts, this deck includes insights from his major works like Give and Take, Originals, and Think Again, along with interactive elements for enhanced engagement.
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.
This presentation has been made keeping in mind the students of undergraduate and postgraduate level. To keep the facts in a natural form and to display the material in more detail, the help of various books, websites and online medium has been taken. Whatever medium the material or facts have been taken from, an attempt has been made by the presenter to give their reference at the end.
In the seventh century, the rule of Sindh state was in the hands of Rai dynasty. We know the names of five kings of this dynasty- Rai Divji, Rai Singhras, Rai Sahasi, Rai Sihras II and Rai Sahasi II. During the time of Rai Sihras II, Nimruz of Persia attacked Sindh and killed him. After the return of the Persians, Rai Sahasi II became the king. After killing him, one of his Brahmin ministers named Chach took over the throne. He married the widow of Rai Sahasi and became the ruler of entire Sindh by suppressing the rebellions of the governors.
2. ● This module introduces the participants to the string
object.
● Importance of String Objects and How to create them.
● Varioius Constructors that are available to create
Strings.
● Working with methods that are available with strings.
● Understanding Necessity of StringBuffer class.
● Working with methods of StringBuffer class.
● Introduction to StringBuilder class.
● Working with methods of StringBuilder class.
Module Overview
2
3. Uderstand the concept of Strings and create string
objects.
Understand advantages and disadvantages of Strings.
Declare and create Strings using different types of
constructors.
Working with Strings and its different types of
methods.
Determine the usage of String Buffer and
StringBuilder.
Objectives
3
4. String: Strings are a sequence of characters, which are
implemented as objects.
Charecteristics of Strings:
• The String class is immutable,meaning once created
a String object cannot be changed.
• If any modifications is done to the existing string
object a new object is created internally.
• String objects are created by using the new keyword
and a constructor. The String class has eleven
constructors that allow you to provide the initial
value of the string using different sources, such as an
array of characters.
String
4
5. String Declaration
String Declaration: The most direct way to create a
string is as follows;
String greeting = "Hello world!";//String literal
Other Common Declarations:
String helloString = new String(helloArray);
char[] helloArray = { 'h', 'e', 'l', 'l', 'o', '.'};
6. Example of String Class.
public class StringDemo{
public static void main(String args[]){
char[] helloArray = { 'h', 'e', 'l', 'l', 'o', '.'};
String helloString = new String(helloArray);
String helloString2 = new String(“hello!!!”);
System.out.println( helloString );
}
}
Output:hello.
7. Methods Of String
Accessor:Methods used to obtain information
about an object are known as accessor methods.
One accessor method that you can use with
strings is the length() method, which returns the
number of characters contained in the string
object.
Syntax:
<StringOBject>.length();
Example:
String name = “java”;
int length = name.length();
8. Methods of String(Cont…)
Concatenating Strings:One String can be
concatenated to another string.This will produce
a new string object joining two strings.
Strings are more commonly concatenated with the
+ operator and concat method.
Syntax:
string1.concat(string2);
string1+string2
9. Methods of String(Cont…)
String substring(int beginIndex)
Returns a new string that is a substring of this string.
char[] toCharArray()
Converts this string to a new character array.
String toLowerCase()
Converts all of the characters in this String to lower
case using the rules of the default locale.
String replace(char oldChar, char newChar)
Returns a new string resulting from replacing all
occurrences of oldChar in this string with newChar.
String[] split(String regex)
Splits this string around matches of the given regular
expression.
10. String toString()
This object (which is already a string!) is itself returned.
String toUpperCase()
Converts all of the characters in this String to upper case
using the rules of the default locale.
String trim()
Returns a copy of the string, with leading and trailing
whitespace omitted.
boolean startsWith(String prefix)
Tests if this string starts with the specified prefix.
boolean contentEquals(StringBuffer sb)
Returns true if and only if this String represents the same
sequence of characters as the specified StringBuffer.
Methods of String(Cont…)
11. Working with methods using Strings
Like other values to (parameters)methods, Strings
also can be passed to methods.
Ex:
public String printString(String s) {
System.out.println(s);
return “modified”+s;
}
String newString =printString(new
String(“Java”));//invoking an array
12. Necessity of StringBuffer
String objects are immutable,meaning
modifications to the string object cannot be done
once created. If done a new String Object will be
created in memory.
The StringBuffer and StringBuilder classes are
used when there is a necessity to make alot of
modifications to Strings of characters.
StringBuffer and Stringbuilder can be modified
over and over again with out leaving behind alot
of new unused objects.
13. String Buffers Methods
public StringBuffer append(String s)
Updates the value of the object that invoked the
method. The method takes boolean, char, int,
long, Strings etc.
public StringBuffer reverse()
The method reverses the value of the
StringBuffer object that invoked the method.
public delete(int start, int end)
Deletes the string starting from start index until
end index.
14. String Buffers Methods
void setLength(int newLength)
Sets the length of this String buffer.
int length()
Returns the length (character count) of this string
buffer.
void ensureCapacity(int minimumCapacity)
Ensures that the capacity of the buffer is at least
equal to the specified minimum.
int capacity()
Returns the current capacity of the String buffer.
15. String Builder Methods
int length()
Returns the length (character count) of this string
buffer.
void ensureCapacity(int minimumCapacity)
Ensures that the capacity of the buffer is at least
equal to the specified minimum.
int capacity()
Returns the current capacity of the String buffer.
reverse() :Causes this character sequence to be
replaced by the reverse of the sequence.
16. StringBuilder vs StringBuffer
Below is a table that contains differences between
StringBuilder and StringBuffer.
StringBuffer StringBuilder
It is mutable It is mutable
It is
synchronized,provides
ThreadSafety.
It is non
synchronized.Provides no
ThreadSafety.
Capacity increases
automatically .
Capacity increases
automatically .
17. Excercise
Create an application that will convert a given
character array to a string.
Creat an application that will create a reverse of
a string.
Create an application that uses StringBuffer to
concatinate the user input.
Create an application that uses a StringBuilder
and String Buffer and insert one in another.