ABSTRACT

This chapter provides complete introduction to strings and the string comparisons and conversions. The Java String class has several methods for working with strings, including compare(), concat(), equals(), split(), length(), replace(), compareTo(), intern(), substring(), and so on. Java String class is implemented by the String, StringBuffer, and StringBuilder classes. The built-in substring() method of the Java String class extracts a substring from a specified string using the index values supplied as an argument. StartIndex is inclusive, and endIndex is exclusive when using the substring() technique. This string is converted to the uppercase letter using the Java String toUpperCase() method and lowercase letter using the String toLowerCase() method. The replace() function of the String class replaces all occurrences of the first sequence of characters with the second sequence of characters.