How to delete the first digit from negative number in Java

1 Answer

0 votes
public class MyClass {
    public static void main(String args[]) {
      int n = -8731;
      
      n = Integer.parseInt(Integer.toString(n).substring(2)) * -1;
        
      System.out.println(n);
    }
}



/*
run:

-731

*/

 



answered Jun 4, 2020 by avibootz

Related questions

4 answers 276 views
1 answer 136 views
1 answer 159 views
1 answer 162 views
1 answer 140 views
2 answers 187 views
2 answers 297 views
...