「Java」ラッパーオブジェクトから基本型への変換する

書式
数値.intValue()
使用例

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
package com.arkgame.strudy.java;
public class InterIntDemo {
private static final Integer count = 678;
public static void main(String[] args) {
change();
}
public static void change() {
int resa = count;
System.out.println("変換結果1: " + resa);
int resb = count.intValue();
System.out.println("変換結果2: " + resb);
}
}
package com.arkgame.strudy.java; public class InterIntDemo { private static final Integer count = 678; public static void main(String[] args) { change(); } public static void change() { int resa = count; System.out.println("変換結果1: " + resa); int resb = count.intValue(); System.out.println("変換結果2: " + resb); } }
package com.arkgame.strudy.java;

public class InterIntDemo {

      private static final Integer count = 678;

      public static void main(String[] args) {

            change();

      }

      public static void change() {
            int resa = count;
            System.out.println("変換結果1: " + resa);

            int resb = count.intValue();
            System.out.println("変換結果2: " + resb);
      }

}

実行結果
変換結果1: 678
変換結果2: 678

Java

Posted by arkgame