I have two array lists of objects, I need to compare them by the property value and to return unique. Object has two properties, question and answer, only the objects from list one with unique question should be returned.
*faq(question, answer)*
List<faq> one = new ArrayList<>();
one.add(new faq("question 1", "answer 1"));
one.add(new faq("question 2", "answer 2"));
one.add(new faq("question 3", "answer 3"));
List<faq> two = new ArrayList<>();
two.add(new faq("question 4", "answer 4"));
two.add(new faq("question 5", "answer 5"));
two.add(new faq("question 1", "answer 6"));
two.add(new faq("question 7", "answer 7"));
two.add(new faq("question 8", "answer 8"));
From this code here I want to get objects from list one with questions 2 and 3 since only those two are not contained in list two
faqimplement/overrides theequals(and hashcode) method?List#removeAllmethod? javadocs If you want to leave listonewithout changes, just copy it first.