我正在尝试使用方法删除重复的数字并返回非重复的数字,实际上我现在被困在方法中。这是我的代码:
import javax.swing.JOptionPane;
public class duplicateRemover{
public static void main(String[] args) {
int[] array = new int[5];
for (int i=0; i<array.length;i++) {
String s=JOptionPane.showInputDialog(null,"PLEASE ENTER AN INTEGER:","INTEGERS",JOptionPane.QUESTION_MESSAGE);
array[i] = Integer.parseInt(s);
}
removeDuplicates(array);
for (int i=0; i<array.length;i++) {
JOptionPane.showMessageDialog(null,array[i],"UNIQE INTEGERS",JOptionPane.PLAIN_MESSAGE);
}
}
public static int[] removeDuplicates(int a []) {
int []removedDup=new int[a.length];
for (int i = 0; i < a.length; i++) {
for (int j = i-1; j < a.length; j++){
if (a[i] == a[i]) {
removedDup[i] = j;
break;
}
}