Here you can find the source of atoi(String str)
public static int atoi(String str)
//package com.java2s; public class Main { public static int atoi(String str) { int retVal = 0; for (int i = 0; i < str.length(); i++) { retVal += (str.charAt(i) - '0') * power(1, str.length() - i - 1); }/* ww w. j a va 2s . co m*/ return retVal; } private static int power(int val, int numOfPower) { for (int i = 0; i < numOfPower; i++) { val *= 10; } return val; } }