SlideShare a Scribd company logo
2
Most read
4
Most read
6
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)

PDF
Java Thread Synchronization
Benj Del Mundo
 
PPT
Synchronization.37
myrajendra
 
PPT
Java access modifiers
Srinivas Reddy
 
PPT
Java multi threading
Raja Sekhar
 
PPT
Final keyword in java
Lovely Professional University
 
PPT
Generics in java
suraj pandey
 
PPTX
Java Strings
RaBiya Chaudhry
 
PDF
Java 8 features
NexThoughts Technologies
 
PPTX
Classes objects in java
Madishetty Prathibha
 
PPT
JDBC – Java Database Connectivity
Information Technology
 
PDF
Java ArrayList Tutorial | Edureka
Edureka!
 
PPS
String and string buffer
kamal kotecha
 
PDF
Java 8 Lambda Expressions
Scott Leberknight
 
PPT
PHP - Introduction to Object Oriented Programming with PHP
Vibrant Technologies & Computers
 
PPT
Exception Handling in JAVA
SURIT DATTA
 
PPTX
Collections in-csharp
Lakshmi Mareddy
 
PPTX
Java string handling
Salman Khan
 
PDF
JUnit & Mockito, first steps
Renato Primavera
 
PPTX
Introduction to Spring Boot
Purbarun Chakrabarti
 
Java Thread Synchronization
Benj Del Mundo
 
Synchronization.37
myrajendra
 
Java access modifiers
Srinivas Reddy
 
Java multi threading
Raja Sekhar
 
Final keyword in java
Lovely Professional University
 
Generics in java
suraj pandey
 
Java Strings
RaBiya Chaudhry
 
Java 8 features
NexThoughts Technologies
 
Classes objects in java
Madishetty Prathibha
 
JDBC – Java Database Connectivity
Information Technology
 
Java ArrayList Tutorial | Edureka
Edureka!
 
String and string buffer
kamal kotecha
 
Java 8 Lambda Expressions
Scott Leberknight
 
PHP - Introduction to Object Oriented Programming with PHP
Vibrant Technologies & Computers
 
Exception Handling in JAVA
SURIT DATTA
 
Collections in-csharp
Lakshmi Mareddy
 
Java string handling
Salman Khan
 
JUnit & Mockito, first steps
Renato Primavera
 
Introduction to Spring Boot
Purbarun Chakrabarti
 

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

PPTX
Day_5.1.pptx
ishasharma835109
 
PPTX
String in java
Ideal Eyes Business College
 
PPTX
What is String in Java?
RAKESH P
 
PDF
Java Presentation on the topic of string
RajTangadi
 
PPTX
More about java strings - Immutability and String Pool
Sujit Kumar
 
PPTX
3.1 STRINGS (1) java jksdbkjdbsjsef.pptx
mohithn2004
 
PDF
Java - Strings Concepts
Victer Paul
 
PPT
Strings in javamnjn ijnjun oinoin oinoi .ppt
ShahidSultan24
 
PDF
Lecture 7
Debasish Pratihari
 
PPT
Text processing
Icancode
 
PPT
Java™ (OOP) - Chapter 9: "Strings and Text I/O"
Gouda Mando
 
DOCX
Java R20 - UNIT-5.docx
Pamarthi Kumar
 
PDF
Java R20 - UNIT-5.pdf
Pamarthi Kumar
 
PPT
String Handling
Bharat17485
 
PPTX
Java Strings - using Strings in practice
Joris Schelfaut
 
PPTX
21CS642 Module 3 Strings PPT.pptx VI SEM CSE
VENKATESHBHAT25
 
PPTX
Introduction to Java Strings, By Kavita Ganesan
Kavita Ganesan
 
PPT
8. String
Nilesh Dalvi
 
PPTX
Session 05 - Strings in Java
PawanMM
 
Day_5.1.pptx
ishasharma835109
 
What is String in Java?
RAKESH P
 
Java Presentation on the topic of string
RajTangadi
 
More about java strings - Immutability and String Pool
Sujit Kumar
 
3.1 STRINGS (1) java jksdbkjdbsjsef.pptx
mohithn2004
 
Java - Strings Concepts
Victer Paul
 
Strings in javamnjn ijnjun oinoin oinoi .ppt
ShahidSultan24
 
Text processing
Icancode
 
Java™ (OOP) - Chapter 9: "Strings and Text I/O"
Gouda Mando
 
Java R20 - UNIT-5.docx
Pamarthi Kumar
 
Java R20 - UNIT-5.pdf
Pamarthi Kumar
 
String Handling
Bharat17485
 
Java Strings - using Strings in practice
Joris Schelfaut
 
21CS642 Module 3 Strings PPT.pptx VI SEM CSE
VENKATESHBHAT25
 
Introduction to Java Strings, By Kavita Ganesan
Kavita Ganesan
 
8. String
Nilesh Dalvi
 
Session 05 - Strings in Java
PawanMM
 
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)

PPTX
Mastering ODC + Okta Configuration - Chennai OSUG
HathiMaryA
 
PDF
“Voice Interfaces on a Budget: Building Real-time Speech Recognition on Low-c...
Edge AI and Vision Alliance
 
PDF
[Newgen] NewgenONE Marvin Brochure 1.pdf
darshakparmar
 
PDF
Agentic AI lifecycle for Enterprise Hyper-Automation
Debmalya Biswas
 
PDF
“NPU IP Hardware Shaped Through Software and Use-case Analysis,” a Presentati...
Edge AI and Vision Alliance
 
PPTX
Agentforce World Tour Toronto '25 - MCP with MuleSoft
Alexandra N. Martinez
 
PDF
How do you fast track Agentic automation use cases discovery?
DianaGray10
 
PDF
“Squinting Vision Pipelines: Detecting and Correcting Errors in Vision Models...
Edge AI and Vision Alliance
 
PDF
Future-Proof or Fall Behind? 10 Tech Trends You Can’t Afford to Ignore in 2025
DIGITALCONFEX
 
PDF
The Rise of AI and IoT in Mobile App Tech.pdf
IMG Global Infotech
 
PDF
Reverse Engineering of Security Products: Developing an Advanced Microsoft De...
nwbxhhcyjv
 
PDF
Mastering Financial Management in Direct Selling
Epixel MLM Software
 
DOCX
Python coding for beginners !! Start now!#
Rajni Bhardwaj Grover
 
PDF
The 2025 InfraRed Report - Redpoint Ventures
Razin Mustafiz
 
PDF
LOOPS in C Programming Language - Technology
RishabhDwivedi43
 
PPTX
MuleSoft MCP Support (Model Context Protocol) and Use Case Demo
shyamraj55
 
PDF
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 
PDF
Staying Human in a Machine- Accelerated World
Catalin Jora
 
PDF
Book industry state of the nation 2025 - Tech Forum 2025
BookNet Canada
 
PDF
What’s my job again? Slides from Mark Simos talk at 2025 Tampa BSides
Mark Simos
 
Mastering ODC + Okta Configuration - Chennai OSUG
HathiMaryA
 
“Voice Interfaces on a Budget: Building Real-time Speech Recognition on Low-c...
Edge AI and Vision Alliance
 
[Newgen] NewgenONE Marvin Brochure 1.pdf
darshakparmar
 
Agentic AI lifecycle for Enterprise Hyper-Automation
Debmalya Biswas
 
“NPU IP Hardware Shaped Through Software and Use-case Analysis,” a Presentati...
Edge AI and Vision Alliance
 
Agentforce World Tour Toronto '25 - MCP with MuleSoft
Alexandra N. Martinez
 
How do you fast track Agentic automation use cases discovery?
DianaGray10
 
“Squinting Vision Pipelines: Detecting and Correcting Errors in Vision Models...
Edge AI and Vision Alliance
 
Future-Proof or Fall Behind? 10 Tech Trends You Can’t Afford to Ignore in 2025
DIGITALCONFEX
 
The Rise of AI and IoT in Mobile App Tech.pdf
IMG Global Infotech
 
Reverse Engineering of Security Products: Developing an Advanced Microsoft De...
nwbxhhcyjv
 
Mastering Financial Management in Direct Selling
Epixel MLM Software
 
Python coding for beginners !! Start now!#
Rajni Bhardwaj Grover
 
The 2025 InfraRed Report - Redpoint Ventures
Razin Mustafiz
 
LOOPS in C Programming Language - Technology
RishabhDwivedi43
 
MuleSoft MCP Support (Model Context Protocol) and Use Case Demo
shyamraj55
 
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 
Staying Human in a Machine- Accelerated World
Catalin Jora
 
Book industry state of the nation 2025 - Tech Forum 2025
BookNet Canada
 
What’s my job again? Slides from Mark Simos talk at 2025 Tampa BSides
Mark Simos
 

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