Why Integer.getInteger does not work?

前端 未结 5 1812
你的背包
你的背包 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:22

    I would use the Integer.valueOf(String n) method.

    Integer bestScore = Integer.valueOf(bestMove.get("score"));
    

    From this blog, the reason they gave,

    Integer.getInteger(String) converts a String to a number by assuming the String is the name of a system property numeric representation. In other words. Integer.getInteger("12345") is likely to yield null.

提交回复
热议问题