Mushfiq Mammadov wrote:1. On page 108, “toLowerCase() and toUpperCase()” section, method signatures are:
These method signatures are wrong!
toLowerCase() and
toUpperCase() don't have a
String parameter as you can notice in the provided example code. They can indeed have a
Locale parameter, but that's for localisation which is not on the OCA exam.
Mushfiq Mammadov wrote:2. On page 109, “equals() and equalsIgnoreCase()” section, method signatures are:
The
equals method should indeed use
Object as parameter, because it's a (valid) override of the equals-method from the
Object class. Nothing wrong with the
equalsIgnoreCase method: it takes a
String parameter and you have almost a completely free choice of the name (must be a valid identifier, e.g.
java keywords not allowed). But of course an appropriate meaningful parameter name is preferred (applies also to class names, method nams, variable names and so on). Although this declaration would be completely valid, this parameter name is not really recommended:
Mushfiq Mammadov wrote:3. On page 109, “contains()” section, method signature is:
For the OCA exam you don't need to know the
CharSequence interface (it's not mentioned in the exam topics), so the authors probably simplified the signature using a
String. And luckily for them (and us):
String IS-A
CharSequence so no problem here as well. But because they explain the
CharSequence later on (for the
replace method) it's maybe better to explain it here already and use the same signature as in the Oracle documentation. And for the OCA exam you do need to know what's an interface and what it means when a method parameter has an interface type, so using
CharSequence in the method signature should be no problem at all.
Mushfiq Mammadov wrote:4. On page 110, “replace()” section, method signature is:
Here the same remark applies as with the
equalsIgnoreCase method: you can use any parameter name you like (if a valid identifier). But here it's probably a copy/paste left-over from the variant using the chars. So I would at least use a variable name which indicates you can use this version to replace more than 1 char (a sequence of chars) e.g.
oldChars and
newChars (or of course the parameter names from Oracle documentation)
Hope it helps!
Kind regards,
Roel