Strings in Java

SAIROSHNI

STRINGS

String are used to store text within double quotes.
Generally ,String is a collection of characters .But in java,string is an object that represents a sequence of character.

Example:

String greeting = ''Hello World'';

STRING CLASS METHODS:

String method
string method


  • Length[]- It returns string length.
  • toLowerCase[]- It returns a string in lowercase using specified locale.
  • toUpperCase[]- It returns a string in uppercase using specified locale. 
  • Trim[]- It removes beginning and ending spaces of this string.
  • Concat[]- It concatenates the specified string.
  • Equals[]- It checks the equality of string within the given object.
  • Replace[]- It replace all occurences of the specified curve value.
  • CharAt()- It returns char values for the particular index.
  • CompareTo()- It compares another string, it doesn't check case.
  • Substring(index)- It returns the specified substring index.
  • Valueof[]- It converts given type into string, it is an overloaded method.
  • Boolean[]- It returns true or false after matching the sequence of char values.

  • Indexof[]- It returns the specified char value index starting with given index.


STRING BUFFERS METHODS:

string buffer
string buffer


  • Capacity()-It is used to return current capacity.

  • Append() It is used to append the specified string with this string. The append() method is overloaded like append(char), append(boolean), append(int), append(float), append(double).

  • Insert()- It is used to insert the specified string with this string at the specified position. The insert() method is overloaded like insert(int, char), insert(int, boolean), insert(int, int), insert(int, float), insert(int, double).
  • Replace()-It is used to replace the string from specified startIndex and endIndex.

  • Delete()It is used to delete the string from specified startIndex and endIndex.

  • Reverse()-It is used to reverse the string.

  • CharAt()- It is used to return the character at the specified position.

  • Length()-It is used to return the length of the string.

  • Substring (int beginIndex)-It is used to return the substring from the specified beginIndex.

  • Substring(int beginIndex, int endIndex)- It is used to return the substring from the specified beginIndex and endIndex.


Our website uses cookies to enhance your experience. Learn More
Accept !

GocourseAI

close
send