Find Duplicate in an int value array with nested for loop
public class FindDuplicate { public static void main(String[] args) { int[] arr = {1, 2, 2, 3, 4, 2, 4, 3, 0, 5, 3, 2}; for(int i = 0; i < arr.length; i++){ for(int j = i+1; j < arr.length; j++){ if(arr[i] == arr[j]) System.out.println("Index "+ i +" same as Index "+ j +" with value "+ arr[i]); }//from w w w . j a va2 s .c o m } } }