オブジェクトを生成して値を得る(Integer編)

静的メソッドでオブジェクトを取得する

#codeprettify{{ String s = "125"; Integer obj = Integer.valueOf(s);

int i = obj.intValue(); }} こうすると 文字列"125"を数値として iに代入する

#codeprettify{{ int i = Integer.valueOf(s).intValue()       ↑objと同じ }} としてもよい。


トップ   編集 凍結 差分 バックアップ 添付 複製 名前変更 リロード   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS
Last-modified: 2013-03-12 (火) 09:13:57