SlideShare a Scribd company logo
Java Strings
Sujit Kumar
Zenolocity LLC
String
• Class provided by the JDK.
• Represents character strings, not same as an
array of characters.
• Any string literal such as “abc” represents an
instance of the String class.
• Strings are constant (immutable), CANNOT be
modified after creation.
String API transformations
• Many methods in the String API to transform
the string.
• Gives the impression that Strings can be
modified.
• However, all the methods return a new String,
the original string is unchanged.
• String API methods can be chained.
Important Instance Methods from the
String API
• charAt, compareTo, concat ( + operator), contains
• format
• getChars
• indexOf, isEmpty
• lastIndexOf, Length
• matches
• replace, replaceAll, replaceFirst,
• split, startsWith, substring
• toCharArray, toLowerCase, toUpperCase, trim
Regular Expressions
• Used by the matches method of the String
class.
• Java Regular Expressions Tutorial
Chaining methods
• String orig = “ Hello, how are you? “;
• String modified =
orig.trim().toUpperCase().substring(3,8);
• Each of the above methods returns a new
instance of a String.
• The original String (orig) remains unchanged.
Static Methods of String API
• valueOf  returns the string representation of
different primitive types, char array or any
Object.

More Related Content

Similar to Java strings (20)

PPTX
L13 string handling(string class)
teach4uin
 
PPTX
Java string handling
Salman Khan
 
PDF
String handling(string class)
Ravi Kant Sahu
 
PDF
String handling(string class)
Ravi_Kant_Sahu
 
PPTX
String.pptx
RanjithKumar742256
 
PPTX
Day_5.1.pptx
ishasharma835109
 
PPTX
javastringexample problems using string class
fedcoordinator
 
PPT
Strings in javamnjn ijnjun oinoin oinoi .ppt
ShahidSultan24
 
PPT
String and string manipulation
Shahjahan Samoon
 
PPSX
Java String class
DrRajeshreeKhande
 
PPTX
Java string handling
GaneshKumarKanthiah
 
PPT
Text processing
Icancode
 
PPSX
String and string manipulation x
Shahjahan Samoon
 
PPT
Java căn bản - Chapter9
Vince Vo
 
PPT
Chapter 9 - Characters and Strings
Eduardo Bergavera
 
PPT
Charcater and Strings.ppt Charcater and Strings.ppt
mulualem37
 
PPTX
DOC-20240802-WA0004dgcuhfgbjhfucjv6du..pptx
meganath16032003
 
PPTX
stringstringbuilderstringbuffer-190830060142.pptx
ssuser99ca78
 
PPTX
String, string builder, string buffer
SSN College of Engineering, Kalavakkam
 
PPTX
In the given example only one object will be created. Firstly JVM will not fi...
Indu32
 
L13 string handling(string class)
teach4uin
 
Java string handling
Salman Khan
 
String handling(string class)
Ravi Kant Sahu
 
String handling(string class)
Ravi_Kant_Sahu
 
String.pptx
RanjithKumar742256
 
Day_5.1.pptx
ishasharma835109
 
javastringexample problems using string class
fedcoordinator
 
Strings in javamnjn ijnjun oinoin oinoi .ppt
ShahidSultan24
 
String and string manipulation
Shahjahan Samoon
 
Java String class
DrRajeshreeKhande
 
Java string handling
GaneshKumarKanthiah
 
Text processing
Icancode
 
String and string manipulation x
Shahjahan Samoon
 
Java căn bản - Chapter9
Vince Vo
 
Chapter 9 - Characters and Strings
Eduardo Bergavera
 
Charcater and Strings.ppt Charcater and Strings.ppt
mulualem37
 
DOC-20240802-WA0004dgcuhfgbjhfucjv6du..pptx
meganath16032003
 
stringstringbuilderstringbuffer-190830060142.pptx
ssuser99ca78
 
String, string builder, string buffer
SSN College of Engineering, Kalavakkam
 
In the given example only one object will be created. Firstly JVM will not fi...
Indu32
 

More from Sujit Kumar (20)

PPTX
SFDC Database Basics
Sujit Kumar
 
PPTX
SFDC Database Security
Sujit Kumar
 
PPTX
SFDC Social Applications
Sujit Kumar
 
PPTX
SFDC Other Platform Features
Sujit Kumar
 
PPTX
SFDC Outbound Integrations
Sujit Kumar
 
PPTX
SFDC Inbound Integrations
Sujit Kumar
 
PPTX
SFDC UI - Advanced Visualforce
Sujit Kumar
 
PPTX
SFDC UI - Introduction to Visualforce
Sujit Kumar
 
PPTX
SFDC Deployments
Sujit Kumar
 
PPTX
SFDC Batch Apex
Sujit Kumar
 
PPTX
SFDC Data Loader
Sujit Kumar
 
PPTX
SFDC Advanced Apex
Sujit Kumar
 
PPTX
SFDC Introduction to Apex
Sujit Kumar
 
PPTX
SFDC Database Additional Features
Sujit Kumar
 
PPTX
Introduction to SalesForce
Sujit Kumar
 
PPTX
More about java strings - Immutability and String Pool
Sujit Kumar
 
PPTX
Hibernate First and Second level caches
Sujit Kumar
 
PPTX
Java equals hashCode Contract
Sujit Kumar
 
PPTX
Java Comparable and Comparator
Sujit Kumar
 
PPTX
Java build tools
Sujit Kumar
 
SFDC Database Basics
Sujit Kumar
 
SFDC Database Security
Sujit Kumar
 
SFDC Social Applications
Sujit Kumar
 
SFDC Other Platform Features
Sujit Kumar
 
SFDC Outbound Integrations
Sujit Kumar
 
SFDC Inbound Integrations
Sujit Kumar
 
SFDC UI - Advanced Visualforce
Sujit Kumar
 
SFDC UI - Introduction to Visualforce
Sujit Kumar
 
SFDC Deployments
Sujit Kumar
 
SFDC Batch Apex
Sujit Kumar
 
SFDC Data Loader
Sujit Kumar
 
SFDC Advanced Apex
Sujit Kumar
 
SFDC Introduction to Apex
Sujit Kumar
 
SFDC Database Additional Features
Sujit Kumar
 
Introduction to SalesForce
Sujit Kumar
 
More about java strings - Immutability and String Pool
Sujit Kumar
 
Hibernate First and Second level caches
Sujit Kumar
 
Java equals hashCode Contract
Sujit Kumar
 
Java Comparable and Comparator
Sujit Kumar
 
Java build tools
Sujit Kumar
 
Ad

Recently uploaded (20)

PPTX
Top iOS App Development Company in the USA for Innovative Apps
SynapseIndia
 
PDF
CIFDAQ Weekly Market Wrap for 11th July 2025
CIFDAQ
 
PDF
Agentic AI lifecycle for Enterprise Hyper-Automation
Debmalya Biswas
 
PDF
Exolore The Essential AI Tools in 2025.pdf
Srinivasan M
 
PPTX
Q2 FY26 Tableau User Group Leader Quarterly Call
lward7
 
PDF
How Startups Are Growing Faster with App Developers in Australia.pdf
India App Developer
 
PDF
CIFDAQ Market Insights for July 7th 2025
CIFDAQ
 
PDF
Achieving Consistent and Reliable AI Code Generation - Medusa AI
medusaaico
 
PDF
Log-Based Anomaly Detection: Enhancing System Reliability with Machine Learning
Mohammed BEKKOUCHE
 
PDF
Blockchain Transactions Explained For Everyone
CIFDAQ
 
PPT
Interview paper part 3, It is based on Interview Prep
SoumyadeepGhosh39
 
PDF
SWEBOK Guide and Software Services Engineering Education
Hironori Washizaki
 
PDF
HubSpot Main Hub: A Unified Growth Platform
Jaswinder Singh
 
PDF
Timothy Rottach - Ramp up on AI Use Cases, from Vector Search to AI Agents wi...
AWS Chicago
 
PDF
"Beyond English: Navigating the Challenges of Building a Ukrainian-language R...
Fwdays
 
PPTX
✨Unleashing Collaboration: Salesforce Channels & Community Power in Patna!✨
SanjeetMishra29
 
PDF
[Newgen] NewgenONE Marvin Brochure 1.pdf
darshakparmar
 
PDF
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 
PDF
Transcript: New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
PDF
Reverse Engineering of Security Products: Developing an Advanced Microsoft De...
nwbxhhcyjv
 
Top iOS App Development Company in the USA for Innovative Apps
SynapseIndia
 
CIFDAQ Weekly Market Wrap for 11th July 2025
CIFDAQ
 
Agentic AI lifecycle for Enterprise Hyper-Automation
Debmalya Biswas
 
Exolore The Essential AI Tools in 2025.pdf
Srinivasan M
 
Q2 FY26 Tableau User Group Leader Quarterly Call
lward7
 
How Startups Are Growing Faster with App Developers in Australia.pdf
India App Developer
 
CIFDAQ Market Insights for July 7th 2025
CIFDAQ
 
Achieving Consistent and Reliable AI Code Generation - Medusa AI
medusaaico
 
Log-Based Anomaly Detection: Enhancing System Reliability with Machine Learning
Mohammed BEKKOUCHE
 
Blockchain Transactions Explained For Everyone
CIFDAQ
 
Interview paper part 3, It is based on Interview Prep
SoumyadeepGhosh39
 
SWEBOK Guide and Software Services Engineering Education
Hironori Washizaki
 
HubSpot Main Hub: A Unified Growth Platform
Jaswinder Singh
 
Timothy Rottach - Ramp up on AI Use Cases, from Vector Search to AI Agents wi...
AWS Chicago
 
"Beyond English: Navigating the Challenges of Building a Ukrainian-language R...
Fwdays
 
✨Unleashing Collaboration: Salesforce Channels & Community Power in Patna!✨
SanjeetMishra29
 
[Newgen] NewgenONE Marvin Brochure 1.pdf
darshakparmar
 
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 
Transcript: New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
Reverse Engineering of Security Products: Developing an Advanced Microsoft De...
nwbxhhcyjv
 
Ad

Java strings

  • 2. String • Class provided by the JDK. • Represents character strings, not same as an array of characters. • Any string literal such as “abc” represents an instance of the String class. • Strings are constant (immutable), CANNOT be modified after creation.
  • 3. String API transformations • Many methods in the String API to transform the string. • Gives the impression that Strings can be modified. • However, all the methods return a new String, the original string is unchanged. • String API methods can be chained.
  • 4. Important Instance Methods from the String API • charAt, compareTo, concat ( + operator), contains • format • getChars • indexOf, isEmpty • lastIndexOf, Length • matches • replace, replaceAll, replaceFirst, • split, startsWith, substring • toCharArray, toLowerCase, toUpperCase, trim
  • 5. Regular Expressions • Used by the matches method of the String class. • Java Regular Expressions Tutorial
  • 6. Chaining methods • String orig = “ Hello, how are you? “; • String modified = orig.trim().toUpperCase().substring(3,8); • Each of the above methods returns a new instance of a String. • The original String (orig) remains unchanged.
  • 7. Static Methods of String API • valueOf  returns the string representation of different primitive types, char array or any Object.