Online Training Spring Hibernate Training in Delhi R Programming Training Course Big Data and Hadoop Training Java Training  

What it will return ..... ?



Share on Google+Share on Google+

What it will return ..... ?
0 Answer(s)      5 years and 8 months ago
Posted in : Java Interview Questions
import java.util.*;
public class Name {
private final String first, last;
public Name(String first, String last) {
this.first = first;
this.last = last;
public boolean equals(Object o) {
if (!(o instanceof Name))
return false;
Name n = (Name)o;
return n.first.equals(first) && n.last.equals(last);
public static void main(String[] args) {
Set<Name> s = new HashSet<Name>();
s.add(new Name("Mickey", "Mouse"));
System.out.println(s.contains(new Name("Mickey", "Mouse")));
View Answers

Related Tutorials/Questions & Answers: