Find out duplicate number between 1 to n numbers in java
public class Main{ public static void main(String[] args){ int [] arr = new int [] {10,34,56,67,10,56,3}; System.out.println("Duplicate elements are "); 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(arr[j]); } } } }