Java: String Exercises 1 - Answers
Answers to the String Exercises 1.
- 3 -- s refers to exactly the same string as a.
- ERROR -- t is a local variable, and it must be assigned a value first.
- "1abc" -- + means concatenation here because an operand is type String
- "ABC"
- 4
- 6
- "mo"
- false -- the string is "3abc"
- true -- they are the same string (== to test for same objects)
- true -- Use .equals to test for same value. Here it is
likely that a.substring(1,3) == "bc" is false.