[Solved] Find duplicate number in array and print the last duplicate number only [closed]
Simple way is iterate and compare it. like below, I hope it may solve your problem int[] a = {1,2,2,3,4,3,5,5,7}; String b = “”; int count=0; for(int i = 0; i<a.length;i++){ for(int j=0; j<a.length;j++){ if(a[i]==a[j]){ count++; } } if(count>1){ count=0; b = String.valueOf(a[i]); }else{ count = 0; } } System.out.println(“last duplicate value : ” + … Read more