1duplicates = false;
2
3for(i = 0; i < zipcodeList.length; i++) {
4 for(j = i + 1; k < zipcodeList.length; j++) {
5 if(j != i && zipcodeList[j] == zipcodeList[i]) {
6 duplicates = true;
7 }
8 }
9}
1System.out.print("Duplicate Characters in above string are: ");
2for (int i = 0; i < str.length(); i++) {
3 for (int j = i + 1; j < str.length(); j++) {
4 if (carray[i] == carray[j]) {
5 System.out.print(carray[j] + " ");
6 break;
7 }
8 }
9}
1// Uses a set, which does not allow duplicates
2
3for (String name : names)
4{
5 if (set.add(name) == false)
6 {
7 // print name your duplicate element
8 }
9}
1 for (String name : names) {
2 if (set.add(name) == false) {
3 // your duplicate element
4 }
5}