LoginSignup
2
0

More than 5 years have passed since last update.

JAVA char同士連結→数字になる

Last updated at Posted at 2015-11-27
public class Test06 {
    public static void main(String[] args) {
        char i = 'D';
        char i2 = 'B';
        int code = (int) i;
        System.out.println(code);
        int code2 = (int) i2;
        System.out.println(code2);
        System.out.println(code + code2);
        code2 = code;
        System.out.println(code2);
        System.out.println(i2);
        System.out.println((char) 66);
        System.out.println((char) 97);
        System.out.println((int) 'b');
        System.out.println((int) 'd');
        String num = Integer.toString(code);
        System.out.println(num);

        int i3 = 5;
        String num2 = Integer.toString(i3);
        System.out.println(num2);
        System.out.println(num2.toString());
        System.out.println(i + i2);
        // char同士の連結については、Stringに変換してからでないと正しい値が出ない

    }

}

■実行結果
68
66
134
68
B
B
a
98
100
68
5
5
134

2
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
0