源码如下:/***Returnsan{@codeInteger}instancerepresentingthespecified*{@codeint}value.Ifanew{@codeInteger}instanceisnot*required,thismethodshouldgenerallybeusedinpreferenceto*theconstructor{@link#Integer(int)},asthismethodislikely*toyieldsignificantlybetterspaceandtimeperformanceby*cachingfrequentlyrequestedvalues.**Thismethodwillalwayscachevaluesintherange-128to127,*inclusive,andmaycacheothervaluesoutsideofthisrange.**@paramian{@codeint}value.*@returnan{@codeInteger}instancerepresenting{@codei}.*@since1.5*/publicstaticIntegervalueOf(inti){if(i>=IntegerCache.low&&i<=IntegerCache.high)returnIntegerCache.cache[i+(-IntegerCache.low)];returnnewInteger(i);}inti=Integer.valueOf(-120);System.out.println(i);//i=-120
慕标琳琳
繁星淼淼
相关分类