用数组输入10个数,这个也没有给提示

img

img

?什么问题???
代码呢


public class Out {

    public static void main(String[] args) {
        Map<String,Integer> map = new HashMap<>(10);
        for (int i = 1;i<11;i++) {
            System.out.println("请输入第"+i+"个数字:");
            Scanner scanner = new Scanner(System.in);
            int in = scanner.nextInt();
            add(map,in);
        }
        System.out.println(map);
    }

    public static void add(Map<String,Integer> map,int i) {
        if (i >= 1 && i<=3) {
            switch (i) {
                case 1:
                    map.put("1的个数:",map.get("1的个数:") == null ? 1 : map.get("1的个数:") + 1);
                    break;
                case 2:
                    map.put("2的个数:",map.get("2的个数:") == null ? 1 : map.get("2的个数:") + 1);
                    break;
                case 3:
                    map.put("3的个数:",map.get("3的个数:") == null ? 1 : map.get("3的个数:") + 1);
                    break;
                default:
            }
        }else {
            map.put("非法的个数:",map.get("非法的个数:") == null ? 1 : map.get("非法的个数:") + 1);
        }

    }
}
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        int[] val = new int[4];
        Scanner scanner = new Scanner(System.in);
        for (int i = 0; i < 10; i++) {
            System.out.print("请输入第" + (i + 1) + "个数字:");
            int v = scanner.nextInt();
            if (v >= 1 && v <= 3) {
                val[v - 1]++;
            } else {
                val[3]++;
            }
        }
        System.out.println("1的个数:" + val[0]);
        System.out.println("2的个数:" + val[1]);
        System.out.println("3的个数:" + val[2]);
        System.out.println("非法的个数:" + val[3]);
    }
}

运行示例:

img