-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathString Methods
More file actions
28 lines (28 loc) · 3.97 KB
/
String Methods
File metadata and controls
28 lines (28 loc) · 3.97 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
Methods Description
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
contains() Checks whether the string contains a substring.
substring() Returns the substring of the string.
join() Joins 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() Replaces 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 or 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.