0% found this document useful (0 votes)
4 views7 pages

StringBuffer StringBuilder StringTokenizer Class Methods in Java by Deepak Smart Programming Lyst9030

The document explains the differences between the equals() method and the == operator in Java, highlighting that equals() compares object content while == compares references. It also details the StringBuffer and StringBuilder classes, noting their differences in synchronization and performance. Additionally, it introduces the StringTokenizer class and its methods for tokenizing strings.

Uploaded by

Aakash Kumar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views7 pages

StringBuffer StringBuilder StringTokenizer Class Methods in Java by Deepak Smart Programming Lyst9030

The document explains the differences between the equals() method and the == operator in Java, highlighting that equals() compares object content while == compares references. It also details the StringBuffer and StringBuilder classes, noting their differences in synchronization and performance. Additionally, it introduces the StringTokenizer class and its methods for tokenizing strings.

Uploaded by

Aakash Kumar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

Smart Programming : Channel

An investment in Knowledge pays the best interest….

StringBuffer, StringBuilder &


StringTokenizer class methods
in Java
Smart Programming (Mohali, Chandigarh India)
Call or Whats App Online & Industrial Training: +91 62838-30308

=> What is difference between equals() and == ?


-> NOTE :
1. equals() method is the "Object" class method.
Object class equals() method compare the
reference of 2 objects (address comparison)
2. String class overrides the equals() method of
Object class

 == operator is used for reference comparison or


address comparison
 equals() method is used for content comparison

1
Smart Programming (Mohali, Chandigarh India)
Call or Whats App Online & Industrial Training: +91 62838-30308

=> StringBuffer class :-


 In some cases using String objects is not
helpful because String objects are immutable
but we want to update the same string object. If
we want to update the string object again and
again then java has provided one class i.e.
StringBuffer class
 NOTE : In case of StringBuffer string mutable
object is created

 StringBuffer is the class thus it has some


constructors and methods

2
Smart Programming (Mohali, Chandigarh India)
Call or Whats App Online & Industrial Training: +91 62838-30308

=> StringBuilder class :-


 StringBuilder is same as StringBuffer but one
difference is that all the methods of
StringBuilder are non-synchronized but all the
methods of StringBuffer are synchronized

=> What is difference between StringBuffer &


StringBuilder :-
1. StringBuffer methods are synchronized
StringBuilder methods are non-synchronized

1. StringBuffer follows the sequential execution


StringBuilder follows the parallel execution

2. StringBuffer will take more execution time


StringBuilder will take less execution time

3
Smart Programming (Mohali, Chandigarh India)
Call or Whats App Online & Industrial Training: +91 62838-30308

3. In case of StringBuffer application performance


is slow
In case of StringBuilder application performance
is fast

4. StringBuffer is threadsafe
StringBuilder is not threadsafe

5. StringBuffer provides the guarantee for data


consistency
StringBuilder does not provides the guarantee
for data consistency

6. StringBuffer came in JDK 1.0 version


StringBuilder came in JDK 1.5 version

4
Smart Programming (Mohali, Chandigarh India)
Call or Whats App Online & Industrial Training: +91 62838-30308

=> StringTokenizer :-
 StringTokenizer is the class which is used to
divide the strings into tokens
 Methods :-
1. hasMoreTokens()
2. nextToken()
3. countTokens()

4. hasMoreElements()
5. nextElement()

5
Smart Programming (Mohali, Chandigarh India)
Call or Whats App Online & Industrial Training: +91 62838-30308

Company Links & Contacts

Company Name: Smart Programming (+91 62838-30308)

Address : Chandigarh & Mohali (Punjab), India

Websites: https://www.smartprogramming.in/
https://courses.smartprogramming.in

Android App:
https://play.google.com/store/apps/details?id=com.sma
rtprogramming

YouTube Channel:
https://www.youtube.com/c/SmartProgramming

You might also like