题目:
编写一个方法,它以二进制形式显示char类型的值。使用多个不同的字符来展示它。
解答:
import java.util.*;
public class chapterThree {
public static void main(String[] args){
System.out.println("A: " + Integer.toBinaryString('A')); // A: 65
System.out.println("!: " + Integer.toBinaryString('!')); // !: 33
System.out.println("x: " + Integer.toBinaryString('x')); // x: 120
System.out.println("7: " + Integer.toBinaryString('7')); // 7: 55
}
}
结果如下:
如果觉得不错的话,就用点赞或者关注来代替五星好评吧!谢谢了!