Many useful methods for performing operations on a sequence of char values are available in the java.lang.String class.
No. | Method | Description |
---|---|---|
1 | char charAt(int index) | It returns the char value for the given index. |
2 | int length() | It returns the string length. |
3 | static String format(String format, Object… args) | It returns a formatted string. |
4 | static String format(Locale l, String format, Object… args) | It returns a formatted string in the locale specified. |
5 | String substring(int beginIndex) | For a given begin index, it returns a substring. |
6 | String substring(int beginIndex, int endIndex) | It returns substring for the given begin index and end index. |
7 | boolean contains(CharSequence s) | After matching the sequence of char values, it returns true or false. |
8 | static String join(CharSequence delimiter, CharSequence… elements) | It returns a joined string. |
9 | static String join(CharSequence delimiter, Iterable<? extends CharSequence> elements) | It returns a joined string. |
10 | boolean equals(Object another) | It compares the string to the given object to see if they are equal. |
11 | boolean isEmpty() | It determines if the string is empty. |
12 | String concat(String str) | The specified string is concatenated. |
13 | String replace(char old, char new) | All occurrences of the specified char value are replaced. |
14 | String replace(CharSequence old, CharSequence new) | It replaces all occurrences of the specified CharSequence. |
15 | static String equalsIgnoreCase(String another) | It makes a comparison with another string. It does not perform a case check. |
16 | String[] split(String regex) | It returns a split string that matches the regex pattern. |
17 | String[] split(String regex, int limit) | It returns a split string matching regex and limit. |
18 | String intern() | It returns an interned string. |
19 | int indexOf(int ch) | It returns the specified char value index. |
20 | int indexOf(int ch, int fromIndex) | It starts with the given index and returns the specified char value index. |
21 | int indexOf(String substring) | It returns the specified substring index. |
22 | int indexOf(String substring, int fromIndex) | It returns the specified substring index starting with the given index. |
23 | String toLowerCase() | It returns a string in lowercase. |
24 | String toLowerCase(Locale l) | It returns a string in lowercase using a specified locale. |
25 | String toUpperCase() | It returns a string in uppercase. |
26 | String toUpperCase(Locale l) | It returns an uppercase string in the specified locale. |
27 | String trim() | It removes the beginning and ending spaces of this string. |
28 | static String valueOf(int value) | It converts the specified type to a string. It’s a method that’s been overworked. |
Also read about the Strings in Java
Follow Me
If you like my post, please follow me to read my latest post on programming and technology.
https://www.instagram.com/coderz.py/
https://www.facebook.com/coderz.py
Staying up to the mark is what defines me. Hi all! I’m Rabecca Fatima a keen learner, great enthusiast, ready to take new challenges as stepping stones towards flying colors.
Leave a Comment