1.

What are the different string methods in Java?

Answer»

There are various string operations in Java that allow us to work with strings. These methods or operations can be USED for string handling in Java as well as string manipulation in Java. Some of such methods are as follows:

  • split(): Split/divide the string at the specified regex.
  • compareTo(): COMPARES two strings on the basis of the Unicode value of each string character.
  • compareToIgnoreCase(): Similar to compareTo, but it also ignores case differences.
  • length(): Returns the length of the specified string.
  • substring(): Returns the substring from the specified string.
  • equalsIgnoreCase(): Compares two strings IGNORING case differences.
  • contains(): CHECKS if a string contains a substring.
  • trim(): Returns the substring after removing any leading and trailing whitespace from the specified string.
  • charAt(): Returns the character at specified index.
  • toLowerCase(): Converts string characters to lower case.
  • toUpperCase(): Converts string characters to upper case.
  • concat(): Concatenates two strings.


Discussion

No Comment Found