Method | Description | Return Type |
charAt() | This method takes an integer value as the index number and returns the character in that index. | char |
chars() | The Java String chars() method is used to return a stream of code points for characters in a string value. | Stream |
codePointAt() | When we want to get the Unicode of a character in a specific index, we use this method. | int |
codePointBefore() | Just like the codePointAt() method, this one also returns the Unicode of the character but of the one that is before the index number specified as the argument to the method. | int |
codePointCount() | This method returns the number of Unicode in the range that we set as the argument of the method. | int |
compareTo() | This method is used to compare two string values lexicographically (character by character). | int |
compareToIgnoreCase() | The method is used to compare two string values just like the compareTo() method but without considering the case differences. | int |
concat() | This method is used to concatenate two string values together. | String |
contains() | The method is used to check if the target string has the specified sequence of characters (That we specify as the argument) | boolean |
contentEquals() | This method is used to check if the character sequence that we set as the argument of the method, is the same as the content of the target string itself. | boolean |
copyValueOf() | This method takes a character array and it will return a string representation of that array. | String |
endsWith() | Via this method we can check and see if the target String ends with the specified sequence of characters | boolean |
equals() | Via this method we can compare two string objects based on their content. | boolean |
equalsIgnoreCase() | This method is used to compare two string values together, ignoring the case considerations. | boolean |
format() | This method is used to return a formatted string. | String |
getBytes() | Via this method we can return the array of bytes that represents the string. | byte[] |
getChars() | This method turns the string content into characters and put it in the target char array that we set as its argument. | void |
hashCode() | This method returns the hash code of a string | int |
indexOf() | This method takes a character sequence and returns the index of the first occurrence in the target string. | int |
indent() | The Java String indent() method is used to add indentation at the beginning of a string value. | String |
intern() | This method is used to store a copy of a String object that is created via the new keyword into the string pool and returns a reference of the pooled object. | String |
isEmpty() | Via this method we can check and see if the string is empty or not. | boolean |
isBlank() | The Java String isBlank() method is used to check a string value and see if it’s empty or contains only white spaces | boolean |
lastIndexOf() | This method is used to find the index number of the last occurrence of the specified sequence of characters. | int |
length() | via this method we can get the length (number of characters) of a String. | int |
lines() | The Java String lines() method is used to create a stream of lines from a string value. | Stream |
matches() | This method takes a regular expression and checks to see if the string matches this expression. | boolean |
regionMatches() | This method is used to check if parts of two strings matches. | boolean |
replace() | This method is used to search for a character and replace it with another character and returns the new string. | String |
replaceFirst() | This method takes two arguments. The first one is a regular expression and the second one is a string. The method will match the regular expression against the target String object and the first match will be replaced by the string that we set as the second argument of the method. | String |
replaceAll() | Just like replaceFirst() method, this one also works the same way. The difference is that, this method will replace all the matches with the string value that we set as the second argument of the method. | String |
repeat() | This method is used to repeat the value of a String object multiple times and return the result, as a new String object. | String |
split() | This method is used to split a string into an array of substrings | String[] |
strip() | The Java String strip() method is used to remove any white space from the leading and trailing parts of a string value. | String |
stripLeading() | The Java String stripLeading() method is used to remove any white space from the leading part (start) of a string value. | String |
stringTrailing() | The Java String stripTrailing() method is used to remove any white space from the trailing part (end) of a string value. | String |
startsWith() | This method is used to check if the string object starts with the specified characters. | boolean |
substring() | This method is used to take a portion of a string and return it as a new String-object. | String |
toCharArray() | Via this method we can convert a string into character array. | char[] |
toString() | via this method we can get the value that is stored in a String object | String |
toUpperCase() | This method is used to convert all the characters of a String into uppercase letters and return a new String-object. | String |
trim() | Via this method we can remove whitespaces from both sides of a string | String |
toLowerCase() | This method is used to convert a string into lowercase letters | String |
valueOf() | This method is used to convert different data types into String object. | String |