T. Anthony Chen<br />---------------<br />SCJP, SCJD, SCBCD, SCWCD, SCEA
Originally posted by Oliver Roell:
Hello ranchers,
this is the method-signature of my find-method:
public int[] find(String[] criteria);
And the assignment says:
Returns an array of record numbers that match the specified criteria.
My find-implementation returns null, when no record is found. Is this correct, or could this lead to an automatic failure or to a deduction of my score?
The assignment says only "Returns an array of record numbers that match the specified criteria" and NOT "Returns an array of record numbers that match the specified criteria, else returns null".
Thus I am not sure, whether I MUST return an empty int-array when no record matches the criteria.
I think, it's a good design to return a null-value when a create-, build- or find-method wasn't successful, but I don't know if I fulfill the requirements in this specific case.
Could anyone help me, please?
Regards,
Oliver
Anton Golovin ([email protected]) SCJP, SCJD, SCBCD, SCWCD, OCEJWSD, SCEA/OCMJEA [JEE certs from Sun/Oracle]
SCJP 1.4, SCJD
Originally posted by Marlene Miller:
>> One of the golden rules is
In Effective Java, Joshua Bloch calls it an idiom - Item 27: Return zero-length arrays, not nulls.
Anton Golovin ([email protected]) SCJP, SCJD, SCBCD, SCWCD, OCEJWSD, SCEA/OCMJEA [JEE certs from Sun/Oracle]
Originally posted by Oliver Roell:
Hello ranchers,
this is the method-signature of my find-method:
public int[] find(String[] criteria);
And the assignment says:
Returns an array of record numbers that match the specified criteria.
My find-implementation returns null, when no record is found. Is this correct, or could this lead to an automatic failure or to a deduction of my score?
The assignment says only "Returns an array of record numbers that match the specified criteria" and NOT "Returns an array of record numbers that match the specified criteria, else returns null".
Thus I am not sure, whether I MUST return an empty int-array when no record matches the criteria.
I think, it's a good design to return a null-value when a create-, build- or find-method wasn't successful, but I don't know if I fulfill the requirements in this specific case.
Could anyone help me, please?
Regards,
Oliver