java中引号的问题

来源:互联网 发布:淘宝店铺简介怎么写 编辑:程序博客网 时间:2024/06/05 20:54

字符串用双引号,如"aaaaaa"

字符用单引号,如‘a’

数字不要引号,如100



举例:

class Demo{
public static void main(String[] args){
int a=2;
System.out.println("a"+a);//此处a代表字符串,通过连接符与其他值相连
}

}输出为:a2


class Demo{
public static void main(String[] args){
int a=2;
System.out.println(‘a’+a);//此处a代表字符,会转化为ascii中对应的值与数值进行运算
}

}输出为:99

0 0