我正在尝试以下代码:-

HashMap<Integer,Integer[]> possibleSeq = new HashMap<Integer,Integer[] >();
        possibleSeq.put(0,new Integer[]{1,4,5});
        possibleSeq.put(1,new Integer[]{0,4,5,2,6});
        Integer[] store = possibleSeq.get(0);
        for(int i=0;i<store.length;i++)
        {
            System.out.print(store[i] + ' ');
        }


输出为:-

333637


但是由于我将key为0时的值等于存储变量,所以我打算将作为输出。因此我推论1 4 5这不是将Integer[] store = possibleSeq.get(0);元素存储在store中的正确方法。我应该怎么做?

最佳答案

您的问题是您要将char ' '(将其转换为int 32)添加到int的store [i]中。

请改用双引号。

System.out.print(store[i] + " ");

08-18 10:42
查看更多