public static void main(String[] args) {
int a = 5;
int [] array = new int []{1,2,4,5,2,5,7,5,2,8,1};
for(int i = 0; i < array.length; i++){
if(array[i] == a){
System.out.println(i);
}
}
}
int number = 5;
List<Integer> repeatedIndex = new ArrayList<>();
int[] numbers = {1,2,4,5,2,5,7,5,2,8,1};
for(int i = 0; i < numbers.length(); i++)
{
if(numbers[i].equals(number);
{
repeatedIndex.add(i);
}
}
public static void main(String[] args) {
int[] array = { 1, 2, 4, 5, 2, 5, 7, 5, 2, 8, 1 };
int[] indices = IntStream.range(0, array.length).filter(i -> array[i] == 5).toArray();
System.out.println(Arrays.toString(indices));
}