17. hashCode()

This method is used to get the hashcode of the string object.

18. indexOf()

This method is used to find the index of a particular character in the string.

19. intern()

It can be used to return a string from memory if it is created by a new keyword. It creates a string object in the String Constant Pool which is an exact copy of the heap string object.
While creating an object in the string pool, the JVM checks whether the string is already present in the pool or not. If the string is present, its reference is returned else new object is created in the string pool. If we remove the intern() from the below example then the output will be false since 2 different objects will be created for the string even their values are the same. Hence intern method saves the memory.

20. isEmpty()

This method is used to check if the string is empty or not.

21. lastIndexOf()

This method is used to get the last occurred index position for a particular character.

22. length()

This method is used to calculate the length of the string.

23. matches()

This is used to check if the given string matches with the regular expression or not.

Related Posts