We are required in our assignment to find the second smallest integer in one array recursively. However, for the sake of understanding the subject more, I want to do it iter
public static void main(String[] args) {
int arr[] = {6,1,37,-4,12,46,5,64,21,2,-4,-3};
int lowest =arr[0];
int sec_lowest =arr[0];
for(int n : arr){
if (lowest > n)
{
sec_lowest = lowest;
lowest = n;
}
else if (sec_lowest > n && lowest != n)
sec_lowest = n;
}
System.out.println(lowest+" "+sec_lowest);
}