如何使用HashMap并在Java中的HashMap中打印出HashMap的值?

时间:2017-04-04 21:28:36

标签: java hashmap

这是我的Qode:

    vehicle SMH9296 = new vehicle("car", "S MH 9296", 0, 0);

    HashMap <Integer, Object> HashMapLevel = new HashMap <Integer, Object>()
    HashMap <Integer, vehicle> HashMapSlot = new HashMap <Integer, vehicle>();
    HashMapSlot.put(1, SMH9296);    

    HashMapLevel.put(0, HashMapSlot);

    for (Object i : HashMapLevel.values()) {
        for (vehicle vehicle : i.values()) { //here is the Problem
            System.out.println(vehicle.getLicencePlate());
        }
    }

错误是:方法值()未定义为Object

类型

但是我的对象应该是一个载体,我应该能够获得这样的值。

我不明白为什么这不起作用。

1 个答案:

答案 0 :(得分:-1)

你走了:

var textarea = document.getElementById('textarea1')
var email = document.getElementById('email')

function updateText() {
  email.value = textarea.value
}

textarea.addEventListener('input', updateText)

// At start...
updateText()
<fieldset>
  <legend> Mail </legend>

  <form action="" method="post">
    Enter your comments here: <br />
    <textarea id="textarea1" rows="30" cols="50">hallo</textarea> <br />

    Your Email here:
    <input type="email" name="email" id="email">
    <input type="submit" value="send">
    <input type="reset" value="reset form">
  </form>
</fieldset>

注意:不要忘记HTML属性值周围的“”(即使它是JS代码)