What does the substring method of the String class do?

  • Checks if the string is empty.
  • Converts the string to lowercase.
  • Retrieves the string's length.
  • Returns a new string with a portion of the original string.
The substring() method of the String class in Java returns a new string that is a subset of the original string. It takes two parameters, the starting index and the ending index, and extracts the characters within that range, creating a new string. The other options do not describe the functionality of the substring() method.
Add your answer
Loading...

Leave a comment

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