My logic is messed up. I am just trying to work out a way to remove duplicates in an ArrayList without using a HashSet.
public static void main(String[] args) {
ArrayList<String> wordDulicate = new ArrayList<String>();
wordDulicate.add("Tom");
wordDulicate.add("Jones");
wordDulicate.add("Sam");
wordDulicate.add("Jamie");
wordDulicate.add("Robie");
wordDulicate.add("Helen");
wordDulicate.add("Tom");
wordDulicate.add("Troy");
wordDulicate.add("Mika");
wordDulicate.add("Tom");
for (String dupWord : wordDulicate) {
if (wordDulicate.equals(dupWord))
System.out.println(wordDulicate.get(dupWord));
}
}
HashSet
prohibited by the teacher? :) – Lenettefor (int dupWord : wordDulicate) {
compiling? – ZarebadupWord
should be aString
not anint
– Rumphif(wordDulicate.equals(dupWord))
... – Bulldog