Java入門第三季3-1代碼問題,代碼在編譯器里有警告
Integer?score2=new?Integer(score1);
為什么這一步會有警告呢?警告說的是The construtor integer(int) is deprecate,IDE為2017版的Eclipse.
Integer?score2=new?Integer(score1);
為什么這一步會有警告呢?警告說的是The construtor integer(int) is deprecate,IDE為2017版的Eclipse.
2017-12-31
舉報
2017-12-31
警告一般不影響,應該是將原值int轉(zhuǎn)換為了一個對象,給的警告
2020-07-17
請問一下,valueOf()?方法不是要把字符串轉(zhuǎn)換成int類型嗎?只能對數(shù)字起作用嗎?
2018-03-14
源碼里面有寫
Deprecated. It is rarely appropriate to use this constructor. The static factory valueOf(int) is generally a better choice, as it is likely to yield significantly better space and time performance.
這個方法已經(jīng)過時了,推薦使用的方法是valueOf(int)
你可以試試使用 Integer score2 = Integer.valueOf(score1);就沒問題了