I was supposed to write this code so that ArrIg is a static nested class of Pair. However, I declared them as independent classes, but the code still ran as expected. I understand why it still ran.
I understand that static prevents the ArrIg object from being called once Pair is called(assuming ArrIg was a nested class of Pair). Further, this violated the syntax for static nested class, but it still worked. What are some of the dangers I have exposed this code to ?
public class ClassPair {
  public static void main(String[] args) {
    // TODO Auto-generated method stub
    int[] Ig= {1,2,3,4};
    Pair pair= ArrIg.minmax(Ig);
    System.out.print("min :"+pair.getFirst()+" | max :"+pair.getSecond());
  }
}
class Pair {
  public Pair(int a, int b){
    first=a;
    second=b;
  }
  public int getFirst(){
    return first;
  }
  public int getSecond(){
    return second;
  }
  private int first, second=0;    
}
class ArrIg{
  public static Pair minmax(int [] a){
    int min= a[0];//1
    int max=a[0];//1
    for(int i=0; i<a.length;i++){
      if (min>a[i]) min =a[i];//1
      if (max<a[i]) max=a[i];//2,3,4
    }
    return new Pair(min ,max);
  }
}
 
    