Witam mam Hashmape z obiektami Double, String.
jeśli String nie jest pusty czy nie jest nullem to chce, żeby jego klucz ( Double ) przyjął wartość tego stringa.
Przyklad:
Double doubleOne = null;
String stringOne = "2.2";
to chcę żeby doubleOne sparsował i przyjął wartość tego stringa.
/* This is how to declare HashMap */
HashMap<Double, String> hmap = new HashMap<Double, String>();
Double doubleOne = null;
String stringOne = "2.2";
/* Adding elements to HashMap */
hmap.put(doubleOne, stringOne);
/* Display content using Iterator */
Set set = hmap.entrySet();
Iterator iterator = set.iterator();
while (iterator.hasNext()) {
Map.Entry mentry = (Map.Entry) iterator.next();
if (mentry.getValue() != null && !((String) mentry.getValue()).isEmpty()) {
mentry.getKey() = Double.parseDouble((String) mentry.getValue());
}
Gdy chce przypisać do mentry.getKey() wartość wyskakuje bląd :
- The left-hand side of an assignment must be a variable