我正在尝试以下代码: -
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] + ' ');
}
Run Code Online (Sandbox Code Playgroud)
输出是: -
333637
Run Code Online (Sandbox Code Playgroud)
但由于我等同值时,关键是0到店变量,我打算让1 4 5作为output.So我推断Integer[] store = possibleSeq.get(0);这是不存储的元素的适当方式possibleSeq.get(0)在商店我应该怎么做.所以?
Tal*_*ala 13
您的问题是您要将char ' '(转换为int 32)添加到store [i],即int.
请改用双引号.
System.out.print(store[i] + " ");
Run Code Online (Sandbox Code Playgroud)
System.out.print(store[i] + ' ');
Run Code Online (Sandbox Code Playgroud)
如要打印(store[i] + ' '),' '是char这里它与整数值并打印串联,所以它成为(1 + 32)作为空间ASCII值()为32,其是33等等...
试试这个 -
System.out.print((store[i]) + " ");
Run Code Online (Sandbox Code Playgroud)
有用 -
1 4 5
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
94 次 |
| 最近记录: |