title: How can I remove the zeros from an integer?
body: <p>How can I remove all the zero's from an integer?
  If the int is only a zero, it will return 0 but if it isn't , it returns an integer that is the same except it doesn't have any 0's.</p>
  
  <p>I tried to pass it to a String and then to an integer after the removal was done, but it comes with the 0's again.</p>
  
  <p>How can I do it?</p>
  
  <pre><code>    public static void main(String[] args) {
  
          // test method removeZeros
          test_removeZeros(0); // result = 0
          test_removeZeros(2); // result = 2
          test_removeZeros(10); // result = 1
          test_removeZeros(101); // result = 11
          test_removeZeros(10050); // result = 15
          test_removeZeros(-30100); // result = -31
          System.out.println();
  
      }
  
      private static void test_removeZeros(int n) {
  
          try {
  
              System.out.print("removeZeros (" + n + ") = ");
              int res = removeZeros(n);
              System.out.println(res);
  
          } catch (IllegalArgumentException e) {
              System.out.println("Error: " + e.getMessage());
          }
      }
  
      private static int removeZeros(int n) {
              int finalresult= n;
              int result;
              String medium;
  
  
              if (n == 0){
  
                  result= 0;
                  result= finalresult;
  
              } else{
  
                  medium= Integer.toString(n);        
                  int x = Integer.parseInt(medium.substring(0));
                  result= Integer.valueOf(medium);
                  result= finalresult;
  
              }
  
              finalresult = result;
              return finalresult;
  
          }
  </code></pre>