怎么设定一个数值然后让其表达出来

img


我是想设定 i 为一个数值 然后让他打印出来
可是int i = "28".nextInt();一直再报错

int i=sc.nextInt()就好了。28是你要用键盘输入的

阁下说的可是这个?

    public static void main(String[] args) {
        Scanner sc = new Scanner("6");
        int i = sc.nextInt();
        System.out.println(i);
    }