0% found this document useful (0 votes)
3 views2 pages

Java String Functions

This document provides a complete reference for Java String functions, detailing various methods such as length(), charAt(), substring(), and more. Each function is briefly described, indicating its purpose and usage. The document serves as a comprehensive guide for working with strings in Java.

Uploaded by

S.S Verma
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)
3 views2 pages

Java String Functions

This document provides a complete reference for Java String functions, detailing various methods such as length(), charAt(), substring(), and more. Each function is briefly described, indicating its purpose and usage. The document serves as a comprehensive guide for working with strings in Java.

Uploaded by

S.S Verma
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
You are on page 1/ 2

Java String Functions - Complete Reference

length()

Returns the length of the string.

charAt(int index)

Returns the character at the specified index.

substring(int beginIndex)

Returns a substring from beginIndex to end.

substring(int beginIndex, int endIndex)

Returns a substring between beginIndex and endIndex.

equals(Object another)

Compares the content of strings.

equalsIgnoreCase(String another)

Compares strings ignoring case.

compareTo(String another)

Compares two strings lexicographically.

toLowerCase()

Converts all characters to lowercase.

toUpperCase()

Converts all characters to uppercase.

trim()

Removes whitespace from beginning and end.

replace(char old, char new)

Replaces all old characters with new.

contains(CharSequence s)

Checks if string contains the specified sequence.

indexOf(int ch)

Returns index of first occurrence of character.

lastIndexOf(int ch)

Returns index of last occurrence of character.

startsWith(String prefix)

Checks if string starts with the specified prefix.

endsWith(String suffix)

Checks if string ends with the specified suffix.


split(String regex)

Splits the string around matches of the regex.

isEmpty()

Checks if the string is empty.

join(CharSequence delimiter, CharSequence... elements)

Joins the strings with a delimiter.

valueOf(primitive data type)

Converts data type to string.

You might also like