Java 习题 (19)

题目:
编写一个方法,它以二进制形式显示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
    }
}

结果如下:
在这里插入图片描述
如果觉得不错的话,就用点赞或者关注来代替五星好评吧!谢谢了!

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值