Java - Change int to ascii

前端 未结 7 892
迷失自我
迷失自我 2020-12-01 07:32

Is there a way for java to convert int\'s to ascii symbols?

7条回答
  •  醉梦人生
    2020-12-01 08:17

    Do you want to convert ints to chars?:

    int yourInt = 33;
    char ch = (char) yourInt;
    System.out.println(yourInt);
    System.out.println(ch);
    // Output:
    // 33
    // !
    

    Or do you want to convert ints to Strings?

    int yourInt = 33;
    String str = String.valueOf(yourInt);
    

    Or what is it that you mean?

提交回复
热议问题