Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Fill in the blanks on the method has Duplicates, which returns true if a stringl

ID: 3772216 • Letter: F

Question

Fill in the blanks on the method has Duplicates, which returns true if a stringlist contains duplicate names. You can use the contains method, defined, defined below, which returns true if (and only if) the argument name is contained in the stringlist. //contains("c") of list ("a", "b","c", "d") returns true contains ("e") of list ("a", "b", "c" , "d") returns false public boolean contains (string name) { if (value.equals (name)) { if value.equals (name) { return true; } else if (next == null) { return false; } else { return next. contains (name); } } public boolean has Duplicates () { if (next== null) { return-; } else if (next.contains(-)) { return-; } else { return - ; } }

Explanation / Answer

// contains ("c") of list ("a", "b", "c", "d") returns true
// contains ("e") of list ("a", "b", "c", "d") returns false
public boolean contains (String name) {
if (value.equals(name)) {
return true;
} else if (next == null) {
return false;
} else {
return next.contains(name);
}

}

public boolean hasDuplicates() {
if (next == null) {
return false;
} else if (next.contains(value)) {
return true;
} else {
return false;
}
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote