You are viewing a single comment's thread. Return to all comments →
static int B; static int H; static boolean flag =true; static{ Scanner sc =new Scanner(System.in); B=sc.nextInt(); H=sc.nextInt(); sc.close(); try{ if(B<=0 || H<=0){ flag=false; throw new Exception ("Breadth and height must be positive") ; }} catch(Exception e){ System.out.println(e); System.exit(0); }
}
Seems like cookies are disabled on this browser, please enable them to open this website
Java Static Initializer Block
You are viewing a single comment's thread. Return to all comments →
static int B; static int H; static boolean flag =true; static{ Scanner sc =new Scanner(System.in); B=sc.nextInt(); H=sc.nextInt(); sc.close(); try{ if(B<=0 || H<=0){ flag=false; throw new Exception ("Breadth and height must be positive") ; }} catch(Exception e){ System.out.println(e); System.exit(0); }
}