Answer the question
In order to leave comments, you need to log in
What is the problem with HashMap?
Good afternoon. There was a problem while writing a term paper in Java.
When accessing HashMap I get this error.
Exception in thread "main" java.lang.NullPointerException: Cannot invoke "pt.Kun.getId()" because "kun" is null
at PT_semestralni/pt.Letoun.naplanujLet(Letoun.java:271)
at PT_semestralni/pt.Simulace.spustSimulace(Simulace.java:33)
at PT_semestralni/pt.Main.main(Main.java:32)
Kun kun = CteniDat.koneHashMap.get(idAktualnihoKone);
System.out.printf("Kun cislo: %d, Hmotnost: %d, X: %f \n",kun.getId(), kun.getHmotnost(), kun.getSourX());
Kun cislo: 5, Hmotnost: 1000, X: 992229,190000
Answer the question
In order to leave comments, you need to log in
That is, the object "kun" can no longer be NULL
What is the problem with HashMap?you don’t even understand in anything
At the same time, on line 271, I output this to the console:
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question