fork(2) download
  1. public class Main {
  2. public static void main(String[] args) {
  3. long num = -10;
  4. int digits = 0;
  5. if (num < 0)
  6. num *= (-1);
  7. if (num < 10 && num >= 0)
  8. digits = 1;
  9. else {
  10. while(num > 0) {
  11. num /= 10;
  12. digits++;
  13. }
  14. }
  15. System.out.println("Digits: " +digits);
  16. }
  17.  
  18. }
Success #stdin #stdout 0.03s 711168KB
stdin
Standard input is empty
stdout
Digits: 2