Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
61 views

Methods of Java String

This document lists and describes various string methods in Java, including methods to check for substrings, extract substrings, join strings with delimiters, replace characters, convert between string and byte arrays, compare strings, trim whitespace, format strings, split strings, convert case, and check properties of strings. It provides the method name and a brief description of what each string method does.

Uploaded by

Yibeltal Gashaw
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
61 views

Methods of Java String

This document lists and describes various string methods in Java, including methods to check for substrings, extract substrings, join strings with delimiters, replace characters, convert between string and byte arrays, compare strings, trim whitespace, format strings, split strings, convert case, and check properties of strings. It provides the method name and a brief description of what each string method does.

Uploaded by

Yibeltal Gashaw
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Methods of Java String

Besides those mentioned above, there are various string methods present in


Java. Here are some of those methods:
Methods Description

contains() checks whether the string contains a substring

substring() returns the substring of the string

join() join the given strings using the delimiter

replace() replaces the specified old character with the specified new character

replaceAll() replaces all substrings matching the regex pattern

replaceFirst() replace the first matching substring

charAt() returns the character present in the specified location

getBytes() converts the string to an array of bytes

indexOf() returns the position of the specified character in the string

compareTo() compares two strings in the dictionary order

compareToIgnoreCase() compares two strings ignoring case differences

trim() removes any leading and trailing whitespaces

format() returns a formatted string

split() breaks the string into an array of strings

toLowerCase() converts the string to lowercase

toUpperCase() converts the string to uppercase


valueOf() returns the string representation of the specified argument

toCharArray() converts the string to a char array

matches() checks whether the string matches the given regex

startsWith() checks if the string begins with the given string

endsWith() checks if the string ends with the given string

isEmpty() checks whether a string is empty of not

intern() returns the canonical representation of the string

contentEquals() checks whether the string is equal to charSequence

hashCode() returns a hash code for the string

subSequence() returns a subsequence from the string

You might also like