Java atoi atoi(final String s, final int def)

Here you can find the source of atoi(final String s, final int def)

Description

atoi

License

Open Source License

Declaration

public static int atoi(final String s, final int def) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    public static int atoi(final String s, final int def) {
        int result = 0;
        int i = 0;
        final int len = s.length();
        int digit;
        while (i < len) {
            digit = s.charAt(i++) - '0';
            if (digit < 0 || 9 < digit)
                return def;
            result = result * 10 + digit;
        }//from   w ww  .  jav a  2 s .c  o  m
        return result;
    }
}

Related

  1. atoi(byte[] s)
  2. atoi(byte[] s, int offset)
  3. atoi(final String s, final int base)
  4. atoi(final String str, final int def)
  5. atoi(Object s)
  6. atoi(String s)
  7. atoi(String s)