I'm doing some past exam papers in preparation for a forthcoming exam, and have come across this question, and I'm not sure how to solve it, I've written a for-each loop with an if statement but I'm not sure what the header would be and what to return. Any help would be great. Thanks.
The question:
An ArrayList named classList is used to store Student objects.
Write code for a method that determines whether or not data for a student with given forename and surname is present in classList.
Something like:
boolean lala( Student given ) {
for( Student s : classList ) {
if( s.getForename().equals( given.getForename() ) &&
s.getSurname().equals( given.getSurname() ) ) {
return true;
}
}
return false;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With