SlideShare a Scribd company logo
7
Most read
12
Most read
13
Most read
Java Strings Tutorial | String Manipulation in Java | Java Tutorial For Beginners | Edureka
Java String Creating a String Hands On
String Pool String Methods
JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training
Java String
Object 01
String is a Java
object
Characters 02
Class 03
Immutable 04
Represents a sequence
of characters
java.lang.String class is used to
create and manipulate strings
A string is immutable
in nature
JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training
The quick brown fox jumps over the lazy dogThe quick brown fox jumps over the lazy dog
The quick fox jumps The quick lazy dog
Java Strings
The quick brown fox jumps over the lazy dogSearch
Create Substring
Create new strings The quick brown fox jumps over the lazy dog
With Strings in Java you can perform various operations, some of which are:
JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training
Java Strings
java.lang.String
JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training
Java Strings
java.lang.String
ComparableSerializable CharSequence
public final class String
extends Object
implements Serializable, Comparable<String>, CharSequence
JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training
Comparable interface is used for ordering the objects of any user-defined class. This interface is
found in java.lang.package and contains only one method named compareTo(Object)
A CharSequence interface is a readable sequence of characters. This interface provides uniform,
read-only access to various kind of character sequences
Serializable is a marker interface that contains no data member or method. It is used to “mark”
the java classes so that objects of these classes may get a specific capability
Java Strings
Comparable
Serializable
CharSequence
JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training
java,lang.StringBuffer is a peer class
of String that represents growable and
writable character sequences
java.lang.StringBuilder is identical to
StringBuffer except for one important
difference that it is not synchronized, which
means it is not thread safe
java.lang.String class is used to create string
objects and provides a list of methods to
create and manipulate Strings
Java Strings
CharSequence
String StringBuffer StringBuilder
String Pool
JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training
String Pool
Java String pool refers to collection of Strings which
are stored in heap memory
As String objects are immutable in nature the
concept of String Pool came into the picture
String Pool helps in saving space for Java Runtime
Heap Memory
String Pool
Literal
new
Keyword
Creating a String
JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training
Literal
new
Keyword
Creating a String – Using Literal
Java String literal is created by using double quotes
String str = “Edureka”;
Heap Memory
String Pool
Edureka
str
str1
String str2 = “Welcome”;str2
Welcome String str1 = “Edureka”;
Before creating a String literal first looks for String with same value in the String pool, if found it
returns the reference else it creates a new String in the pool & returns the reference
JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training
Literal
new
Keyword
Creating a String – Using new Keyword
Heap Memory
String Pool
Edureka
Welcome
str
str1
str2
Edureka str3
String object created using “new” keyword it always create a new object in heap memory
String str = new String (“Edureka”);
String Methods
JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training
String Methods
boolean equals(Object another) Checks the equality of string with the given object
equalsIgnoreCase() Compares another string without matching the case
length() Returns a strings length
charAt(i) Returns a character at a index ‘i’
toUpperCase() Returns the string in uppercase
toLowerCase() Returns the string in lowercase
replace(oldVal, newVal) Replaces all occurrences of the specified char value with the given value
trim() Removes the white spaces from the beginning and ending of string
contains("value") Checks for the matching sequence of char value and returns true/false
toCharArray() Converts a string to a new character array
IsEmpty() Checks whether the string is empty or not
endsWith() Checks if the string ends with the specified suffix
concat() Concatenates two strings
Java Strings Tutorial | String Manipulation in Java | Java Tutorial For Beginners | Edureka

More Related Content

What's hot (20)

PPT
Java Collections Framework
Sony India Software Center
 
PPTX
History Of JAVA
ARSLANAHMED107
 
PDF
Java 8-streams-collectors-patterns
José Paumard
 
PPTX
Java Method, Static Block
Infoviaan Technologies
 
PPT
Core java concepts
Ram132
 
PPTX
Static keyword ppt
Vinod Kumar
 
PDF
Java Basic Oops Concept
atozknowledge .com
 
PDF
07 java collection
Abhishek Khune
 
ODP
Multithreading In Java
parag
 
PPTX
Core java complete ppt(note)
arvind pandey
 
PPT
Generics in java
suraj pandey
 
PPTX
Java Constructor
MujtabaNawaz4
 
PPTX
String in java
Ideal Eyes Business College
 
PPTX
Lecture - 2 Environment setup & JDK, JRE, JVM
manish kumar
 
PPT
Java Programming for Designers
R. Sosa
 
PDF
Java exception handling ppt
JavabynataraJ
 
PPTX
File handling
priya_trehan
 
PPT
JAVA OOP
Sunil OS
 
PPSX
Arrays in Java
Hitesh-Java
 
PDF
Java: The Complete Reference, Eleventh Edition
moxuji
 
Java Collections Framework
Sony India Software Center
 
History Of JAVA
ARSLANAHMED107
 
Java 8-streams-collectors-patterns
José Paumard
 
Java Method, Static Block
Infoviaan Technologies
 
Core java concepts
Ram132
 
Static keyword ppt
Vinod Kumar
 
Java Basic Oops Concept
atozknowledge .com
 
07 java collection
Abhishek Khune
 
Multithreading In Java
parag
 
Core java complete ppt(note)
arvind pandey
 
Generics in java
suraj pandey
 
Java Constructor
MujtabaNawaz4
 
Lecture - 2 Environment setup & JDK, JRE, JVM
manish kumar
 
Java Programming for Designers
R. Sosa
 
Java exception handling ppt
JavabynataraJ
 
File handling
priya_trehan
 
JAVA OOP
Sunil OS
 
Arrays in Java
Hitesh-Java
 
Java: The Complete Reference, Eleventh Edition
moxuji
 

Similar to Java Strings Tutorial | String Manipulation in Java | Java Tutorial For Beginners | Edureka (20)

PDF
Java String
Java2Blog
 
PPTX
What is String in Java?
RAKESH P
 
PDF
Java - Strings Concepts
Victer Paul
 
PPTX
Day_5.1.pptx
ishasharma835109
 
PDF
Lecture 7
Debasish Pratihari
 
DOCX
Java67
Nagesh Halgonde
 
DOCX
Java interview questions and answers for cognizant By Data Council Pune
Pankaj kshirsagar
 
PPT
Core_java_ppt.ppt
SHIBDASDUTTA
 
PPTX
Java String
SATYAM SHRIVASTAV
 
PPTX
JAVA AND OOPS CONCEPTS.pptx helpful for engineering
PriyanshuGupta101797
 
PDF
Java Interview Questions PDF By ScholarHat
Scholarhat
 
PPTX
OCA Java SE 8 Exam Chapter 3 Core Java APIs
İbrahim Kürce
 
PDF
Java R20 - UNIT-5.pdf
Pamarthi Kumar
 
PPTX
Session 05 - Strings in Java
PawanMM
 
PPT
09slide
Dorothea Chaffin
 
PPT
JavaYDL9
Terry Yoast
 
DOCX
Java R20 - UNIT-5.docx
Pamarthi Kumar
 
PPTX
Introduction java string
sambhajimeher
 
PPTX
Lecture 9
talha ijaz
 
Java String
Java2Blog
 
What is String in Java?
RAKESH P
 
Java - Strings Concepts
Victer Paul
 
Day_5.1.pptx
ishasharma835109
 
Java interview questions and answers for cognizant By Data Council Pune
Pankaj kshirsagar
 
Core_java_ppt.ppt
SHIBDASDUTTA
 
Java String
SATYAM SHRIVASTAV
 
JAVA AND OOPS CONCEPTS.pptx helpful for engineering
PriyanshuGupta101797
 
Java Interview Questions PDF By ScholarHat
Scholarhat
 
OCA Java SE 8 Exam Chapter 3 Core Java APIs
İbrahim Kürce
 
Java R20 - UNIT-5.pdf
Pamarthi Kumar
 
Session 05 - Strings in Java
PawanMM
 
JavaYDL9
Terry Yoast
 
Java R20 - UNIT-5.docx
Pamarthi Kumar
 
Introduction java string
sambhajimeher
 
Lecture 9
talha ijaz
 
Ad

More from Edureka! (20)

PDF
What to learn during the 21 days Lockdown | Edureka
Edureka!
 
PDF
Top 10 Dying Programming Languages in 2020 | Edureka
Edureka!
 
PDF
Top 5 Trending Business Intelligence Tools | Edureka
Edureka!
 
PDF
Tableau Tutorial for Data Science | Edureka
Edureka!
 
PDF
Python Programming Tutorial | Edureka
Edureka!
 
PDF
Top 5 PMP Certifications | Edureka
Edureka!
 
PDF
Top Maven Interview Questions in 2020 | Edureka
Edureka!
 
PDF
Linux Mint Tutorial | Edureka
Edureka!
 
PDF
How to Deploy Java Web App in AWS| Edureka
Edureka!
 
PDF
Importance of Digital Marketing | Edureka
Edureka!
 
PDF
RPA in 2020 | Edureka
Edureka!
 
PDF
Email Notifications in Jenkins | Edureka
Edureka!
 
PDF
EA Algorithm in Machine Learning | Edureka
Edureka!
 
PDF
Cognitive AI Tutorial | Edureka
Edureka!
 
PDF
AWS Cloud Practitioner Tutorial | Edureka
Edureka!
 
PDF
Blue Prism Top Interview Questions | Edureka
Edureka!
 
PDF
Big Data on AWS Tutorial | Edureka
Edureka!
 
PDF
A star algorithm | A* Algorithm in Artificial Intelligence | Edureka
Edureka!
 
PDF
Kubernetes Installation on Ubuntu | Edureka
Edureka!
 
PDF
Introduction to DevOps | Edureka
Edureka!
 
What to learn during the 21 days Lockdown | Edureka
Edureka!
 
Top 10 Dying Programming Languages in 2020 | Edureka
Edureka!
 
Top 5 Trending Business Intelligence Tools | Edureka
Edureka!
 
Tableau Tutorial for Data Science | Edureka
Edureka!
 
Python Programming Tutorial | Edureka
Edureka!
 
Top 5 PMP Certifications | Edureka
Edureka!
 
Top Maven Interview Questions in 2020 | Edureka
Edureka!
 
Linux Mint Tutorial | Edureka
Edureka!
 
How to Deploy Java Web App in AWS| Edureka
Edureka!
 
Importance of Digital Marketing | Edureka
Edureka!
 
RPA in 2020 | Edureka
Edureka!
 
Email Notifications in Jenkins | Edureka
Edureka!
 
EA Algorithm in Machine Learning | Edureka
Edureka!
 
Cognitive AI Tutorial | Edureka
Edureka!
 
AWS Cloud Practitioner Tutorial | Edureka
Edureka!
 
Blue Prism Top Interview Questions | Edureka
Edureka!
 
Big Data on AWS Tutorial | Edureka
Edureka!
 
A star algorithm | A* Algorithm in Artificial Intelligence | Edureka
Edureka!
 
Kubernetes Installation on Ubuntu | Edureka
Edureka!
 
Introduction to DevOps | Edureka
Edureka!
 
Ad

Recently uploaded (20)

PDF
Agentic AI lifecycle for Enterprise Hyper-Automation
Debmalya Biswas
 
PPTX
MuleSoft MCP Support (Model Context Protocol) and Use Case Demo
shyamraj55
 
PDF
What’s my job again? Slides from Mark Simos talk at 2025 Tampa BSides
Mark Simos
 
PDF
Bitcoin for Millennials podcast with Bram, Power Laws of Bitcoin
Stephen Perrenod
 
PDF
New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
PDF
[Newgen] NewgenONE Marvin Brochure 1.pdf
darshakparmar
 
PPTX
Designing_the_Future_AI_Driven_Product_Experiences_Across_Devices.pptx
presentifyai
 
PPTX
From Sci-Fi to Reality: Exploring AI Evolution
Svetlana Meissner
 
PPTX
Future Tech Innovations 2025 – A TechLists Insight
TechLists
 
PDF
“Voice Interfaces on a Budget: Building Real-time Speech Recognition on Low-c...
Edge AI and Vision Alliance
 
PDF
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 
PDF
Building Real-Time Digital Twins with IBM Maximo & ArcGIS Indoors
Safe Software
 
PDF
Smart Trailers 2025 Update with History and Overview
Paul Menig
 
PDF
"Beyond English: Navigating the Challenges of Building a Ukrainian-language R...
Fwdays
 
PDF
CIFDAQ Market Insights for July 7th 2025
CIFDAQ
 
PDF
POV_ Why Enterprises Need to Find Value in ZERO.pdf
darshakparmar
 
PDF
"AI Transformation: Directions and Challenges", Pavlo Shaternik
Fwdays
 
PDF
Achieving Consistent and Reliable AI Code Generation - Medusa AI
medusaaico
 
PDF
Peak of Data & AI Encore AI-Enhanced Workflows for the Real World
Safe Software
 
PDF
The Rise of AI and IoT in Mobile App Tech.pdf
IMG Global Infotech
 
Agentic AI lifecycle for Enterprise Hyper-Automation
Debmalya Biswas
 
MuleSoft MCP Support (Model Context Protocol) and Use Case Demo
shyamraj55
 
What’s my job again? Slides from Mark Simos talk at 2025 Tampa BSides
Mark Simos
 
Bitcoin for Millennials podcast with Bram, Power Laws of Bitcoin
Stephen Perrenod
 
New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
[Newgen] NewgenONE Marvin Brochure 1.pdf
darshakparmar
 
Designing_the_Future_AI_Driven_Product_Experiences_Across_Devices.pptx
presentifyai
 
From Sci-Fi to Reality: Exploring AI Evolution
Svetlana Meissner
 
Future Tech Innovations 2025 – A TechLists Insight
TechLists
 
“Voice Interfaces on a Budget: Building Real-time Speech Recognition on Low-c...
Edge AI and Vision Alliance
 
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 
Building Real-Time Digital Twins with IBM Maximo & ArcGIS Indoors
Safe Software
 
Smart Trailers 2025 Update with History and Overview
Paul Menig
 
"Beyond English: Navigating the Challenges of Building a Ukrainian-language R...
Fwdays
 
CIFDAQ Market Insights for July 7th 2025
CIFDAQ
 
POV_ Why Enterprises Need to Find Value in ZERO.pdf
darshakparmar
 
"AI Transformation: Directions and Challenges", Pavlo Shaternik
Fwdays
 
Achieving Consistent and Reliable AI Code Generation - Medusa AI
medusaaico
 
Peak of Data & AI Encore AI-Enhanced Workflows for the Real World
Safe Software
 
The Rise of AI and IoT in Mobile App Tech.pdf
IMG Global Infotech
 

Java Strings Tutorial | String Manipulation in Java | Java Tutorial For Beginners | Edureka

  • 2. Java String Creating a String Hands On String Pool String Methods
  • 3. JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training Java String Object 01 String is a Java object Characters 02 Class 03 Immutable 04 Represents a sequence of characters java.lang.String class is used to create and manipulate strings A string is immutable in nature
  • 4. JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training The quick brown fox jumps over the lazy dogThe quick brown fox jumps over the lazy dog The quick fox jumps The quick lazy dog Java Strings The quick brown fox jumps over the lazy dogSearch Create Substring Create new strings The quick brown fox jumps over the lazy dog With Strings in Java you can perform various operations, some of which are:
  • 5. JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training Java Strings java.lang.String
  • 6. JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training Java Strings java.lang.String ComparableSerializable CharSequence public final class String extends Object implements Serializable, Comparable<String>, CharSequence
  • 7. JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training Comparable interface is used for ordering the objects of any user-defined class. This interface is found in java.lang.package and contains only one method named compareTo(Object) A CharSequence interface is a readable sequence of characters. This interface provides uniform, read-only access to various kind of character sequences Serializable is a marker interface that contains no data member or method. It is used to “mark” the java classes so that objects of these classes may get a specific capability Java Strings Comparable Serializable CharSequence
  • 8. JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training java,lang.StringBuffer is a peer class of String that represents growable and writable character sequences java.lang.StringBuilder is identical to StringBuffer except for one important difference that it is not synchronized, which means it is not thread safe java.lang.String class is used to create string objects and provides a list of methods to create and manipulate Strings Java Strings CharSequence String StringBuffer StringBuilder
  • 10. JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training String Pool Java String pool refers to collection of Strings which are stored in heap memory As String objects are immutable in nature the concept of String Pool came into the picture String Pool helps in saving space for Java Runtime Heap Memory String Pool
  • 12. JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training Literal new Keyword Creating a String – Using Literal Java String literal is created by using double quotes String str = “Edureka”; Heap Memory String Pool Edureka str str1 String str2 = “Welcome”;str2 Welcome String str1 = “Edureka”; Before creating a String literal first looks for String with same value in the String pool, if found it returns the reference else it creates a new String in the pool & returns the reference
  • 13. JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training Literal new Keyword Creating a String – Using new Keyword Heap Memory String Pool Edureka Welcome str str1 str2 Edureka str3 String object created using “new” keyword it always create a new object in heap memory String str = new String (“Edureka”);
  • 15. JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training String Methods boolean equals(Object another) Checks the equality of string with the given object equalsIgnoreCase() Compares another string without matching the case length() Returns a strings length charAt(i) Returns a character at a index ‘i’ toUpperCase() Returns the string in uppercase toLowerCase() Returns the string in lowercase replace(oldVal, newVal) Replaces all occurrences of the specified char value with the given value trim() Removes the white spaces from the beginning and ending of string contains("value") Checks for the matching sequence of char value and returns true/false toCharArray() Converts a string to a new character array IsEmpty() Checks whether the string is empty or not endsWith() Checks if the string ends with the specified suffix concat() Concatenates two strings