VARIOUS FUNCTIONS ON STRING

  • toString()

toString() function shows what is there in reference variable. By default, it prints address kept in reference variable. But, toString() can be overrried to show desired output.

  • hashcode()

Hashcode is any unique value assigned to every object present in memory. This function returns that integer value.

  • toUpper()

Converts lowercase letter to uppercase.

  • toLower()

Converts uppercase letter to lowercase.

  • split(String regex)

The java string split() method splits this string against given regular expression(regex) and returns a char array.

  • substring()

Returns new String object containing the substring of the given string from specified startIndex (inclusive).

  • contains(CharSequence c)

This method returns true if and only if this string contains the specified sequence of char values.

  • startswith(CharSequence c)

Returns boolean value , whether  a string starts with the specified prefix beginning a specified index or by default at the beginning.

  • endswith(CharSequence c)

This method returns tests if this string ends with the specified suffix.

Leave a comment