找出字符串数组中不重复的数据并输出所在位置

//目前只考虑数组为数字的情况

public class StringLocation{

public static void main(String[] args) {
String[] arr= new String[]{"2","10","21","15","8","2","20","15","40"};
String[] arr1=new String[arr.length];
int place=1;
for(int per =0;per<arr.length;per++){
arr1[per]=arr[per];
}
for(int lg=0;lg<arr.length-1;lg++){
for(int lgq=0;lgq<arr.length;lgq++){

if(arr1[lg]==arr[lgq]&&lg!=lgq){
arr1[lg]=null;
// System.out.println(arr[lg]);
// System.out.println("重复数据位置"+lg);
}
}
}
// System.out.println(Arrays.toString(arr1));
for(int index =0;index<arr.length;index++,place++){
if(arr1[index]!=null){

System.out.println("位置是"+place);
System.out.println("不重复的数据"+arr1[index]);

}
}

}
}

原文地址:https://www.cnblogs.com/lgqboke/p/5806283.html