We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
importjava.io.*;importjava.util.*;importjava.text.*;importjava.math.*;importjava.util.regex.*;publicclassSolution{staticScannerscan=newScanner(System.in);staticintB=scan.nextInt();staticintH=scan.nextInt();staticbooleanflag=true;static{try{if(B<=0||H<=0){flag=false;thrownewException("Breadth and height must be positive");}}catch(Exceptione){System.out.println(e);}}publicstaticvoidmain(String[]args){if(flag){intarea=B*H;System.out.print(area);}}//end of main}//end of class
Java Static Initializer Block
You are viewing a single comment's thread. Return to all comments →
My solution.