将带字母的字符串数组转换为java中的int数组

mad*_*ter 2 java arrays string int integer

好的我将尝试在这里解释我的问题,我需要做的是将字符串数组转换为int数组.

这是我的一部分(初始设置)

   System.out.println("Please enter a 4 digit number to be converted to decimal ");
    basenumber = input.next();

    temp = basenumber.split("");
    for(int i = 0; i < temp.length; i++)
        System.out.println(temp[i]);

    //int[] numValue = new int[temp.length];
    ArrayList<Integer>numValue = new ArrayList<Integer>();

    for(int i = 0; i < temp.length; i++)
        if (temp[i].equals('0')) 
            numValue.add(0);
        else if (temp[i].equals('1')) 
            numValue.add(1);
                     ........
        else if (temp[i].equals('a') || temp[i].equals('A'))
            numValue.add(10);
                     .........
             for(int i = 0; i < numValue.size(); i++)
        System.out.print(numValue.get(i));
Run Code Online (Sandbox Code Playgroud)

基本上我要做的是将0-9设置为实际数字,然后从输入字符串(例如Z3A7)开始将az设置为10-35,理想情况下将打印为35 3 10 7

Rob*_*arl 5

在循环中尝试这个:

Integer.parseInt(letter, 36);
Run Code Online (Sandbox Code Playgroud)

这将解释letter为base36号码(0-9 + 26个字母).

Integer.parseInt("2", 36); // 2
Integer.parseInt("B", 36); // 11
Integer.parseInt("z", 36); // 35
Run Code Online (Sandbox Code Playgroud)