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 305 views
1 answer 153 views
1 answer 169 views
1 answer 179 views
1 answer 158 views
2 answers 205 views
2 answers 311 views
...