coderz.py

Keep Coding Keep Cheering!

String class methods in Java

java thread class

Many useful methods for performing operations on a sequence of char values are available in the java.lang.String class.

No.MethodDescription
1char charAt(int index)It returns the char value for the given index.
2int length()It returns the string length.
3static String format(String format, Object… args)It returns a formatted string.
4static String format(Locale l, String format, Object… args)It returns a formatted string in the locale specified.
5String substring(int beginIndex)For a given begin index, it returns a substring.
6String substring(int beginIndex, int endIndex)It returns substring for the given begin index and end index.
7boolean contains(CharSequence s)After matching the sequence of char values, it returns true or false.
8static String join(CharSequence delimiter, CharSequence… elements)It returns a joined string.
9static String join(CharSequence delimiter, Iterable<? extends CharSequence> elements)It returns a joined string.
10boolean equals(Object another)It compares the string to the given object to see if they are equal.
11boolean isEmpty()It determines if the string is empty.
12String concat(String str)The specified string is concatenated.
13String replace(char old, char new)All occurrences of the specified char value are replaced.
14String replace(CharSequence old, CharSequence new)It replaces all occurrences of the specified CharSequence.
15static String equalsIgnoreCase(String another)It makes a comparison with another string. It does not perform a case check.
16String[] split(String regex)It returns a split string that matches the regex pattern.
17String[] split(String regex, int limit)It returns a split string matching regex and limit.
18String intern()It returns an interned string.
19int indexOf(int ch)It returns the specified char value index.
20int indexOf(int ch, int fromIndex)It starts with the given index and returns the specified char value index.
21int indexOf(String substring)It returns the specified substring index.
22int indexOf(String substring, int fromIndex)It returns the specified substring index starting with the given index.
23String toLowerCase()It returns a string in lowercase.
24String toLowerCase(Locale l)It returns a string in lowercase using a specified locale.
25String toUpperCase()It returns a string in uppercase.
26String toUpperCase(Locale l)It returns an uppercase string in the specified locale.
27String trim()It removes the beginning and ending spaces of this string.
28static 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

Leave a Comment

Your email address will not be published. Required fields are marked *

Advertisement