Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ember.js/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 为什么HashMap字符串值转换为大写?_Java_Hashmap - Fatal编程技术网

Java 为什么HashMap字符串值转换为大写?

Java 为什么HashMap字符串值转换为大写?,java,hashmap,Java,Hashmap,我已经宣布了一张地图如下: private Map<String, String> mUnsavedFields = new HashMap<>(); 它按预期工作,但当我在循环中获取“username”键的值时 Iterator it = mUnsavedFields.entrySet().iterator(); while (it.hasNext()) { Map.Entry pair = (Map.Entry)it.next(); Timber.d

我已经宣布了一张地图如下:

private Map<String, String> mUnsavedFields = new HashMap<>();
它按预期工作,但当我在循环中获取“username”键的值时

Iterator it = mUnsavedFields.entrySet().iterator();
while (it.hasNext()) {
    Map.Entry pair = (Map.Entry)it.next();
    Timber.d("Key(%s), Value(%S)", pair.getKey(), pair.getValue());
    it.remove(); // avoids a ConcurrentModificationException
}

它返回为“蝙蝠侠”,全大写。为什么会发生这种情况?我如何保留它所使用的确切格式?

%S格式占位符将输入参数大写

标题化结果仅为控制台中显示的打印,值为原始值

使用

发件人:

由大写字符(即“B”、“H”、“S”、“C”、“X”、“e”、“G”、“A”和“T”)表示的转换与相应的小写转换字符的转换相同,只是结果转换为大写

(强调矿山)


您使用了%S,因此它会转换为大写。

请阅读,这是不可能的,可能您正在其他地方修改值。集合不会修改自己放入其中的内容,这将是荒谬的。请包含更多代码。很可能,您正在某个阶段调用
.toUpperCase()
。@CaptRisky我们无法提供帮助,因为您还没有发布一个完整的再现问题的最小示例。哇,这是一个多么糟糕的错误啊,哈哈,干杯,伙计,都分类好了;)为你的帮助干杯
Iterator it = mUnsavedFields.entrySet().iterator();
while (it.hasNext()) {
    Map.Entry pair = (Map.Entry)it.next();
    Timber.d("Key(%s), Value(%S)", pair.getKey(), pair.getValue());
    it.remove(); // avoids a ConcurrentModificationException
}
"Key(%s), Value(%s)"