java.lang.StringIndexOutOfBoundsException: String index out of range: 1

笔者源码如下:

package javaPractice;

import java.util.*;

public class TestScanner {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String str = sc.nextLine();
        ArrayList<Character> a = new ArrayList<Character>();
        int i = 0;
        while(str.charAt(i)!='#') {
            a.add(str.charAt(i));
            System.out.println((int)a.get(i));
            i ++;
        }
        sc.close();
    }
}

//先占个坑,小陌早晚会解决的

猜你喜欢

转载自blog.csdn.net/Moliay/article/details/84726804
今日推荐