No Such Element Exception?

后端 未结 5 1524
南旧
南旧 2020-12-01 23:33

So here is my code:

public static void getArmor(String treasure)
    throws FileNotFoundException{
    Random rand=new Random();
    Scanner file=new Scanner         


        
5条回答
  •  再見小時候
    2020-12-02 00:33

    Another situation which issues the same problem, map.entrySet().iterator().next()

    If there is no element in the Map object, then the above code will return NoSuchElementException. Make sure to call hasNext() first.

提交回复
热议问题