[Go to site: main page, start]

0% found this document useful (0 votes)
6 views12 pages

Java String Methods

The document discusses various methods of the Java String class, including length(), charAt(), concat(), substring(), equals(), contains(), toUpperCase(), and toLowerCase(). Each method is briefly explained with its purpose and functionality. Code examples are suggested for better understanding of these string methods.

Uploaded by

djcmclc
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)
6 views12 pages

Java String Methods

The document discusses various methods of the Java String class, including length(), charAt(), concat(), substring(), equals(), contains(), toUpperCase(), and toLowerCase(). Each method is briefly explained with its purpose and functionality. Code examples are suggested for better understanding of these string methods.

Uploaded by

djcmclc
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

Java

Java String Methods

01
String is one of the important topic in
any programming language.

In this post we will discuss about different


methods of string class. We also see code
example for better understanding.

02
1. int length() Method

The length() method of string in Java is used to


get the length of the string.

03
2. char charAt(int index) Method
This method returns a character at given index
number from the string. index start from 0 to
length-1.

if the given index is not present then


StringIndexOutOfBoundsException will be
thrown.
04
3. String concat(String string1) Method
The concat() method of string in Java is used
for concatenating two strings.

05
4. String substring(int beginIndex, int
endIndex[optional]) method

The substring() method of string in Java


returns the specified part from the string. The
starting index is inclusive while the ending
index is exclusive which simply means that the
substring part will start from the index
beginIndex till endIndex - 1.

06
5. String equals (String string2) method

The equals() method of string in Java is used to


verify if both the strings are equal or not.

07
6. String contains (String substring) Method

The contains() method of string in java is used


to verify if the string contains the specified
part of the string or not.

08
7. String toUpperCase() Method

This method converts all the characters in the


string to uppercase.

09
8. String toLowerCase() Method

This method converts all the characters in the


string to lowercase.

10
Comment Down
More Methods

11
Gunjan Jain

You might also like