SlideShare a Scribd company logo
- Arulkumar V
Assistant Professor, SECE
Java String
What is String in java
12/19/20172
 Generally, string is a sequence of characters.
 But in java, string is an object that represents a
sequence of characters.
 The java.lang.String class is used to create string
object.
 How to create String object?
 There are two ways to create String object:
 By string literal
 By new keyword
12/19/20173
 String Literal
 Java String literal is created by using double
quotes. For Example:
 String s="welcome";
Java String
12/19/20174
 In java, string is basically an object that represents
sequence of char values.
 An array of characters works same as java string.
For example:
 char[] ch={'j','a','v','a','t','p','o','i','n','t'};
String s=new String(ch);
The java.lang.String class
implements Serializable, Comparable and CharSequence
interfaces.
12/19/20175
String methods
12/19/20176
 Java String class provides a lot of
methods to perform operations on string
such as
 compare(), concat(), equals(), split(),
length(), replace(), compareTo(), intern(),
substring() etc.

String Example
12/19/20177
public class StringExample{
public static void main(String args[]){
String s1="java";//creating string by java string literal
char ch[]={'s','t','r','i','n','g','s'};
String s2=new String(ch);//converting char array to string
String s3=new String("example");//creating java string by
new keyword
System.out.println(s1);
System.out.println(s2);
System.out.println(s3);
}}
String methods ex
12/19/20178
public class CharAtExample{
public static void main(String args[]){
String name="javatpoint";
char ch=name.charAt(4);//returns the char value at the 4th index
System.out.println(ch);
}}
public class CharAtExample{
public static void main(String args[]){
String name="javatpoint";
char ch=name.charAt(10);//returns the char value at the 10th
index
System.out.println(ch);
}}
12/19/20179
12/19/201710
Thank You

More Related Content

PPTX
Function-and-prototype defined classes in JavaScript
PDF
PPT
8. String
PPT
10. Introduction to Datastructure
PDF
Handout for Dublin Core Metadata Initiative Abstract Model
ODP
String Interpolation in Scala
PPTX
Session 05 - Strings in Java
PPT
12. Stack
Function-and-prototype defined classes in JavaScript
8. String
10. Introduction to Datastructure
Handout for Dublin Core Metadata Initiative Abstract Model
String Interpolation in Scala
Session 05 - Strings in Java
12. Stack

What's hot (13)

PPT
Standard Template Library
PPTX
Ruby OOP: Objects over Classes
PPT
5. Inheritances, Packages and Intefaces
PPTX
Session 16 - Collections - Sorting, Comparing Basics
PPTX
Java Data Types and Variables
PPT
JavaScript Data Types
PPT
Data types
PPTX
Quick Scala
PPTX
Introduction to OOP in Python
PPSX
Arrays in Java
PPTX
Functions and Objects in JavaScript
PPTX
Python oop - class 2 (inheritance)
PPT
1. Overview of Java
Standard Template Library
Ruby OOP: Objects over Classes
5. Inheritances, Packages and Intefaces
Session 16 - Collections - Sorting, Comparing Basics
Java Data Types and Variables
JavaScript Data Types
Data types
Quick Scala
Introduction to OOP in Python
Arrays in Java
Functions and Objects in JavaScript
Python oop - class 2 (inheritance)
1. Overview of Java
Ad

Similar to String (20)

PPTX
1st.pptx
PPTX
What-is-String-in-Java.pptx
PPTX
Java Strings.pptxJava Strings.pptxJava Strings.pptx
PPTX
Day_5.1.pptx
PPT
String classes and its methods.20
PPTX
Introduction to Java Strings, By Kavita Ganesan
PPT
String and string manipulation
PDF
Java - Strings Concepts
PPTX
21CS642 Module 3 Strings PPT.pptx VI SEM CSE
DOCX
Java R20 - UNIT-5.docx
PDF
Java R20 - UNIT-5.pdf
PPTX
String in java, string constructors and operations
PPTX
Java Strings
PPTX
Java String
PPTX
PDF
Java Presentation on the topic of string
PPT
Text processing
PPTX
String handling
PPSX
String and string manipulation x
PPTX
What is String in Java?
1st.pptx
What-is-String-in-Java.pptx
Java Strings.pptxJava Strings.pptxJava Strings.pptx
Day_5.1.pptx
String classes and its methods.20
Introduction to Java Strings, By Kavita Ganesan
String and string manipulation
Java - Strings Concepts
21CS642 Module 3 Strings PPT.pptx VI SEM CSE
Java R20 - UNIT-5.docx
Java R20 - UNIT-5.pdf
String in java, string constructors and operations
Java Strings
Java String
Java Presentation on the topic of string
Text processing
String handling
String and string manipulation x
What is String in Java?
Ad

More from PhD Research Scholar (20)

PPTX
Quiz servlet
PPTX
servlet db connectivity
PPTX
2.java script dom
PPTX
1.java script
PPTX
Quiz javascript
PPTX
Thread&multithread
PPTX
Streams&io
PPTX
PPTX
Interface in java
PPTX
Inner classes in java
PPTX
PPTX
Exception handling
PPTX
Abstract class
PPTX
7. tuples, set & dictionary
PPTX
PPTX
4. functions
Quiz servlet
servlet db connectivity
2.java script dom
1.java script
Quiz javascript
Thread&multithread
Streams&io
Interface in java
Inner classes in java
Exception handling
Abstract class
7. tuples, set & dictionary
4. functions

Recently uploaded (20)

PDF
A GUIDE TO GENETICS FOR UNDERGRADUATE MEDICAL STUDENTS
PPTX
Final Presentation General Medicine 03-08-2024.pptx
PDF
LDMMIA Reiki Yoga Finals Review Spring Summer
PDF
01-Introduction-to-Information-Management.pdf
PPTX
202450812 BayCHI UCSC-SV 20250812 v17.pptx
PDF
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
PDF
GENETICS IN BIOLOGY IN SECONDARY LEVEL FORM 3
PDF
ChatGPT for Dummies - Pam Baker Ccesa007.pdf
PPTX
Orientation - ARALprogram of Deped to the Parents.pptx
PDF
Trump Administration's workforce development strategy
PPTX
Lesson notes of climatology university.
PDF
What if we spent less time fighting change, and more time building what’s rig...
PPTX
Cell Types and Its function , kingdom of life
PDF
OBE - B.A.(HON'S) IN INTERIOR ARCHITECTURE -Ar.MOHIUDDIN.pdf
PDF
Anesthesia in Laparoscopic Surgery in India
PPTX
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
PPTX
Introduction-to-Literarature-and-Literary-Studies-week-Prelim-coverage.pptx
PDF
Chinmaya Tiranga quiz Grand Finale.pdf
PPTX
master seminar digital applications in india
PDF
Weekly quiz Compilation Jan -July 25.pdf
A GUIDE TO GENETICS FOR UNDERGRADUATE MEDICAL STUDENTS
Final Presentation General Medicine 03-08-2024.pptx
LDMMIA Reiki Yoga Finals Review Spring Summer
01-Introduction-to-Information-Management.pdf
202450812 BayCHI UCSC-SV 20250812 v17.pptx
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
GENETICS IN BIOLOGY IN SECONDARY LEVEL FORM 3
ChatGPT for Dummies - Pam Baker Ccesa007.pdf
Orientation - ARALprogram of Deped to the Parents.pptx
Trump Administration's workforce development strategy
Lesson notes of climatology university.
What if we spent less time fighting change, and more time building what’s rig...
Cell Types and Its function , kingdom of life
OBE - B.A.(HON'S) IN INTERIOR ARCHITECTURE -Ar.MOHIUDDIN.pdf
Anesthesia in Laparoscopic Surgery in India
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
Introduction-to-Literarature-and-Literary-Studies-week-Prelim-coverage.pptx
Chinmaya Tiranga quiz Grand Finale.pdf
master seminar digital applications in india
Weekly quiz Compilation Jan -July 25.pdf

String

  • 1. - Arulkumar V Assistant Professor, SECE Java String
  • 2. What is String in java 12/19/20172  Generally, string is a sequence of characters.  But in java, string is an object that represents a sequence of characters.  The java.lang.String class is used to create string object.  How to create String object?  There are two ways to create String object:  By string literal  By new keyword
  • 3. 12/19/20173  String Literal  Java String literal is created by using double quotes. For Example:  String s="welcome";
  • 4. Java String 12/19/20174  In java, string is basically an object that represents sequence of char values.  An array of characters works same as java string. For example:  char[] ch={'j','a','v','a','t','p','o','i','n','t'}; String s=new String(ch);
  • 5. The java.lang.String class implements Serializable, Comparable and CharSequence interfaces. 12/19/20175
  • 6. String methods 12/19/20176  Java String class provides a lot of methods to perform operations on string such as  compare(), concat(), equals(), split(), length(), replace(), compareTo(), intern(), substring() etc. 
  • 7. String Example 12/19/20177 public class StringExample{ public static void main(String args[]){ String s1="java";//creating string by java string literal char ch[]={'s','t','r','i','n','g','s'}; String s2=new String(ch);//converting char array to string String s3=new String("example");//creating java string by new keyword System.out.println(s1); System.out.println(s2); System.out.println(s3); }}
  • 8. String methods ex 12/19/20178 public class CharAtExample{ public static void main(String args[]){ String name="javatpoint"; char ch=name.charAt(4);//returns the char value at the 4th index System.out.println(ch); }} public class CharAtExample{ public static void main(String args[]){ String name="javatpoint"; char ch=name.charAt(10);//returns the char value at the 10th index System.out.println(ch); }}