集册 Java实例教程 如何声明和使用Java基本char变量

如何声明和使用Java基本char变量

欢马劈雪     最近更新时间:2020-01-02 10:19:05

453
提示:您可在线编辑运行本教程的实例 - 运行实例,去试试!
Java char是16位类型,用于表示Unicode字符。


 

public class Main {
/* 
 来自 
*NowJava.com - 时  代  Java*/

        public static void main(String[] args) {

                char ch1 = 'a';

                char ch2 = 65; /* ASCII code of 'A'*/

               

                System.out.println("Value of char variable ch1 is :" + ch1);   

                System.out.println("Value of char variable ch2 is :" + ch2);             

        }

}