【发布时间】:2015-01-04 15:32:04
【问题描述】:
我想用 for 循环遍历字母表并将每个字母添加到我的HashMap
for(char alphabet = 'A'; alphabet <= 'Z';alphabet++) {
System.out.println(alphabet);
}
对我不起作用,因为我的 HashMap 是形式
HashMap<String, HashMap<String, Student>> hm;
我需要我的迭代器是一个字符串,但是
for(String alphabet = 'A'; alphabet <= 'Z';alphabet++) {
System.out.println(alphabet);
}
没用。
基本上,我想这样做:
for i from 'A' to 'Z' do
hm.put(i, null);
od
有什么想法吗?
【问题讨论】:
-
us 字符而不是字符串 stackoverflow.com/questions/2047228/…
标签: java string loops for-loop