?
package de.codegym.task.task12.task1233;
/*
Die Isomorphen kommen
*/
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
public class Solution {
public static void main(String[] args) throws Exception {
int[] data = new int[]{1, 2, 3, 5, -2, -8, 0, 77, 5, 5};
Pair<Integer, Integer> result = getMinimumAndIndex(data);
System.out.println("Die kleinste Zahl ist " + result.x);
System.out.println("Der Index des kleinsten Elements ist " + result.y);
}
public static Pair<Integer, Integer> getMinimumAndIndex(int[] array) {
if (array == null || array.length == 0) {
return new Pair<Integer, Integer>(null, null);
}
int[] arrayCopy = new int[]{1, 2, 3, 5, -2, -8, 0, 77, 5, 5};
int s= arrayCopy[0];
int index=0;
for(int i=0;i<10;i++){
if(arrayCopy[i]<s){
s=arrayCopy[i];
index=i;}
}
return new Pair<Integer, Integer>(s, index+1);
}
public static class Pair<X, Y> {
public X x;
public Y y;
public Pair(X x, Y y) {
this.x = x;
this.y = y;
}
}
}