import java.util.ArrayList; import java.util.Arrays; import java.util.List; public class arrayDuplicate { public static void main(String[] args) { int[] number=new int[]{1,2,1,5,6,8,2}; for(int i=0;i<=number.length-1;i++){ for(int j=0;j<=number.length-1;j++){ if(number[i]==number[j] && i!=j){ System.out.println("Duplicate number: "+number[i]); } } } } }
No comments:
Post a Comment