首页 > 编程语言 > 详细

Java读取char数据: System.in.read()

时间:2020-05-18 09:54:16      阅读:49      评论:0      收藏:0      [点我收藏+]

 

public class getchar
{
    public static void main(String[] args)
    throws java.io.IOException //必不可少
    {
        int num = System.in.read(); //读进来的数,默认保存为整数,如果需要输出 刚才输入字符,需要用char进行强制转换(type cast)
        char c = (char) num;
        System.out.println("the char you‘ve just input is: " + c + "\nits unicode number is: " + num);
    }
}

 

Java读取char数据: System.in.read()

原文:https://www.cnblogs.com/profesor/p/12908758.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!