-1

Give me with example to find duplicates and display in List/ArrayList without using Set/Map implementation in java? Is it possible? Then how?

Sam
  • 1
  • I'm voting to close this question as off-topic because we are not living in the Stone Age. We have "Google" to look for some things. – TheLostMind Dec 04 '15 at 05:44
  • 1
    Possible duplicate of http://stackoverflow.com/questions/203984/how-do-i-remove-repeated-elements-from-arraylist – Madushan Perera Dec 04 '15 at 05:46

1 Answers1

0

Of course it's possible. The most obvious solution isn't very efficient, but it generates the right answer:

List<String> input = ...
List<String> result = new ArrayList<>();

for (String item : input) {
    if (!result.contains(item)) {
        result.add(item);
    }
}

But why would you want to do this? (Except perhaps to settle a stupid bet).

Ted Hopp
  • 232,168
  • 48
  • 399
  • 521