String functionality
Working with strings in Java can be a little confusing at first because they really are a special case. Strings have associated with them this concept of a string literal, that is, a sequence of characters between double quotation marks. We can just put it right into our Java programs and Java will understand it, just like it would understand an integer number or a single character.
Unlike integers, characters, and floats, Java doesn't have a primitive keyword associated with this string literal. About the closest we could get if we wanted to is a character array; however, generally, Java likes us to associate string literals with the String
class. To understand the String
class better, look at the following program:
package strings; public class Strings { public static void main(String[] args) { String s1 = new String ("Strings are arrays of characters"); String s2 = new String ("Strings are arrays of characters"); ...