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


 

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);
    }
}

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM