//查找某个元素再数组中的索引,考虑数组重复
import java.util.ArrayList;
public class Chazhao {
public static void main(String[] args) throws Exception {
int [] arr={131,121,140,147,81,45,90,81};
System.out.println(search(arr,81));
}
public static ArrayList<Integer> search(int[] arr,int num) {
ArrayList<Integer> indexArr=new ArrayList<>();
for (int i = 0; i < arr.length; i++) {
if(arr[i]==num){
indexArr.add(i);
}
}
return indexArr;
}
}