Why Integer.getInteger does not work?

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

    Because Integer.getInteger is not what you're searching for. From the Javadoc :

    Determines the integer value of the system property with the specified name. The first argument is treated as the name of a system property. System properties are accessible through the System.getProperty(java.lang.String) method. The string value of this property is then interpreted as an integer value and an Integer object representing this value is returned. Details of possible numeric formats can be found with the definition of getProperty.

    If there is no property with the specified name, if the specified name is empty or null, or if the property does not have the correct numeric format, then null is returned.

    You want to use Integer.parseInt

提交回复
热议问题