Why Integer.getInteger does not work?

前端 未结 5 1819
你的背包
你的背包 2021-01-01 14:34

I have the following code:

game.log.fine(\"HERE\" + bestMove.get(\"score\"));
Integer bestScore = Integer.getInteger(bestMove.get(\"score\"));
game.log.fine(         


        
5条回答
  •  长情又很酷
    2021-01-01 15:29

    You should use

    Integer.parseInt
    

    in your code since

    Integer.getInteger
    

    will determine the integer value of the system property with the specified name.

    Correct code would be:

    Integer bestScore = Integer.parseInt(bestMove.get("score"), 10);
    

    That 10 as the second arguments is the radix. Use it always so your number won't be parsed ambigously.

提交回复
热议问题