1

Suppose I have a class:

class Alpha{
   public int x;
   public Alpha(int x){ this.x = x; }
}

and a method which consumes Alpha.

public void method(Alpha alpha){
   if(alpha.x < 5 || alpha.x > 7){
      throw new IllegalArgumentException(...); //IS THIS CORRECT USAGE?
   }

}

Is this usage correct? Technically the Alpha instance is not incorrect, but a field of that is incorrect. What to do?

jjot0
  • 209
  • 2
  • 6

0 Answers0