@@ -0,0 +1,1542 @@
+package leetcode.string_to_integer_atoi;%0A%0Apublic class Solution %7B%0A    public int atoi(String str) %7B%0A    %09if(str == null %7C%7C str.length() == 0) return 0;%0A        char%5B%5D chars = str.trim().toCharArray();%0A        StringBuilder sb = new StringBuilder();%0A        int idx = 0;%0A        boolean negative = false;%0A        if(chars%5Bidx%5D == '+')%7B%0A        %09idx++;%0A        %7D%0A        if(chars%5Bidx%5D == '-')%7B%0A        %09idx++;%0A        %09negative = true;%0A        %7D%0A        boolean nonZero = false;%0A        boolean containDigit = false;%0A        for(;idx %3C chars.length && Character.isDigit(chars%5Bidx%5D); idx++)%7B%0A        %09containDigit = true;%0A        %09if(chars%5Bidx%5D != '0')%7B%0A        %09%09nonZero = true;%0A        %09%7D%0A        %09if(nonZero)%0A        %09%09sb.append(chars%5Bidx%5D);%0A        %7D%0A        if(!containDigit) return 0;%0A        if(sb.length() %3E 10)%7B%0A        %09if(negative) return Integer.MIN_VALUE;%0A        %09else return Integer.MAX_VALUE;%0A        %7Delse%7B%0A        %09if(sb.length() == 10)%7B%0A        %09%09if(negative)%7B%0A        %09%09%09if(sb.toString().compareTo(%222147483648%22) %3E 0)%0A        %09%09%09%09return Integer.MIN_VALUE;%0A        %09%09%7Delse%7B%0A        %09%09%09if(sb.toString().compareTo(%222147483647%22) %3E 0)%0A        %09%09%09%09return Integer.MAX_VALUE;%0A        %09%09%7D%0A        %09%7D%0A        %09int ret = 0;%0A        %09for(char c : sb.toString().toCharArray())%7B%0A        %09%09ret *= 10;%0A        %09%09ret += c - '0';%0A        %09%7D%0A        %09if(negative)%0A        %09%09ret = -ret;%0A        %09return ret;%0A        %7D%0A    %7D%0A    %0A    public static void main(String%5B%5D args)%7B%0A    %09System.err.println(new Solution().atoi(%22   214748364777%22));%0A    %7D%0A%7D%0A

Add java solution for 8. String to Integer (atoi)