Skip to main content

Posts

Showing posts with the label Java Int to String Hackerrank Solution

Java Int to String Hackerrank Solution

 Java Int to String Hackerrank Solution For Explanation Watch Video: Sample Input 0 100 Sample Output 0 Good job Code: import  java.util.*; import  java.security.*; public   class  Solution {   public   static   void  main(String[] args) {   DoNotTerminate.forbidExit();    try  {    Scanner in =  new  Scanner(System.in);     int  n = in .nextInt();    in.close();     //String s=???; Complete this line below     String s = Integer.toString(n);         if  (n == Integer.parseInt(s)) {     System.out.println( "Good job" );    }  else  {     System.out.println( "Wrong answer." );    }   }  catch  (DoNotTerminate.ExitTrappedException e) {    System.out.println( "Unsuccessful Termination!!" );   }  } } //The following class will prevent you from terminating the code using exit(0)! class  DoNotTerminate {   public   static   class  ExitTrappedException  extends  SecurityException {    private   static   final   long  serialVersionUID =  1 ;  }   public   static