Working with Strings

In Java, a group of characters is called a string. Three classes used for character data are Character Class, String Class and String-Buffer Class. The string class is used to create an object of a string and initialise it with a string literal.Once the object is initialised, its content cannot be modified, since it is an immutable string. A string object can be created in two ways using string literals and using new keyword. While creating a string using string literals, the strings are enclosed in double quotes. The string objects immutable in Java because, if one reference variable changes the value of the object, all the other reference variables also get affected. The String class is a class whose instances or objects can hold unchangeable strings, i.e., immutable strings. Once an object is initialised, its content cannot be modified. The accessor methods are used to obtain information about an object. The trim method of the String class is used to return a copy of the string, with leading and trailing whitespace omitted. The object created using String-Buffer class contains a memory block called buffer. The buffer will be empty if, no values will be passed to the object. The StringBuffer class can be used when a lot of modifications need to be made in strings of characters.

To Access the full content, Please Purchase