10. copyValueOf()

This method takes the character array, the initial offset of the subarray, and the length of the subarray and returns the string generated from the input array. In the below example, the initial offset is 3. That is from the 3rd index get 5 elements and generate string. So ‘world’ string is generated.

11. endsWith()

Checks if this string ends with the specified suffix. It returns true/false if the string ends with the suffix or not.

12. equals()

This method checks if two string values are equal or not. It returns true/false based on the match. This is case-sensitive.

13. equalsIgnoreCase()

This is the same as the equals method, but this method is case-insensitive.

14. format()

This method returns the formatted string using java Locale (%s in below example for the string), format string, and arguments. In the below example %s is used for string

15. getBytes()

This method encodes the string into the sequence of bytes and returns the array of bytes.

16. getChars()

This method is used to copy the content of the string into a specified character array. It takes four parameters: begin index of string, end index of string, destination array, and destination array begin index.

String class Methods

Related Posts