
?
In the above code, two strings are evaluated using the equivalency operator. Why can this be a problem, and what other methods are offered by Java for working with characters and strings?
What will be an ideal response?
The problem stems from the fact that in Java, String is a class, and each created String is an object. As an object, a String variable name is not a simple data type. It is a reference; that is, a variable that holds a memory address. Therefore, when you compare two String objects using the == operator, you are comparing not their values but the computer memory locations.?Programmers want to compare the contents of memory locations (the values stored there)more frequently than they want to compare the addresses of the locations. Fortunately, the creators of Java have provided three classes that you can use when working with text data; these classes provide you with many methods that make working with characters and strings easier:?Character - A class whose instances can hold a single character value and whose methods manipulate and inspect single-character data?String - A class for working with fixed-string data; unchanging data composed of multiple characters?StringBuilder and StringBuffer - Classes for storing and manipulating changeable data composed of multiple characters
You might also like to view...
Write a script that outputs HTML text that displays in the HTML document a checkerboard pattern as follows:
``` * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * ```
Used to create a new table from the results of a query
a. Query wizard b. Table query c. Make table query
To save time formatting charts, you can save and apply custom chart ________
Fill in the blank(s) with the appropriate word(s).
When you initialize parallel arrays, it is convenient to use ____ so that the values that correspond to each other visually align on the screen or printed page.
A. tabs B. indentation C. spacing D. dashes