0

我正在尝试制作一个可以找到随机数组模式的程序。到目前为止,我已经找到了一组数字的模式,尽管当数组出现多个模式时我的代码不起作用。顺便说一句,我正在使用 HashMap。这是我的代码:

for(int i = 0; i < arr.length; i++) {

        if (hm.get(arr[i]) != null) {

            int count = hm.get(arr[i]);
            count++;
            hm.put(arr[i], count);

            if(count > max) {
                max  = count;
                temp = arr[i];
            }

谢谢!

4

0 回答 0