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.*;publicclassSolution{privatestaticbooleanflag=true;privatestaticintB;privatestaticintH;static{try(Scannerscanner=newScanner(System.in)){B=scanner.nextInt();H=scanner.nextInt();if(B<=0||H<=0){thrownewException("Breadth and height must be positive");}}catch(Exceptionexception){flag=false;System.out.println(exception);}}publicstaticvoidmain(String[]args){if(flag){intp=B*H;System.out.print(p);}}}
Cookie support is required to access HackerRank
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 →