Java Static Initializer Block

  • + 0 comments

    import java.io.; import java.util.; class soln{ static{ Scanner ob=new Scanner(System.in); int B=ob.nextInt(); int H=ob.nextInt(); int area=B*H;

      if(H<=0 || B<=0) 
      System.out.println("java.lang.Exception: Breadth and height must be positive");
      else
      System.out.println(area);  
    }
    }
    

    public class Solution { public static void main(String[] args) { soln ob1= new soln();

    } }