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 486 views
1 answer 234 views
1 answer 252 views
1 answer 268 views
1 answer 252 views
2 answers 321 views
2 answers 430 views
...