【发布时间】:2021-01-06 17:12:26
【问题描述】:
我有一些想法要这样做
我卡在 if 语句部分,如何进行比较?
这个例子的预期输出是:字符串ones is use two test the map numberthree。
String s = "The string 1s is use 2 test the map number3.";
HashMap<Integer,String> map = new HashMap<>();
map.put(1,"one");
map.put(2,"two");
map.put(3,"three");
for (int i = 0; i < s.length(); i++){
if (s.charAt(i) is equals to map.contains(1){
s[i] = map.get(1);
}
}
【问题讨论】:
标签: java if-statement hash hashmap equals