(Review:) What two things does the following statement do?
A good answer might be:
| |
Easy way to Construct StringsString objects are very useful and are frequently used. To make life easier for programmers, Java has a short-cut way of creating a String object, as follows: String zeta = "The last rose of summer." ; This creates a String object containing the characters between quote marks, just as before. Java also does something to optimize performance, but ignore this for now. A String created in this short-cut way is called a String literal. Only Strings have a short-cut like this. All other objects are constructed by using the new operator. Some methods require a parameter that is a reference to a String object. For example,
The String refered to by stringA has an equals() method. That method is called with a parameter, a reference to stringB. The method checks if both strings contain identical characters, and if so, evaluates to true ("returns true").
Careful:
The previous paragraph is accurate, but awkward.
Almost always people say
"The equals method of stringA is called with stringB".
This is fine,
as long as you remember that a variable like | |
QUESTION 2:(Review:) Examine the following snippet of code: String a; Point b;
|