大家好,又见面了,我是你们的朋友全栈君。
展开全部
1、在JAVA程序中由String和“+”参与的运算变量都会被转为字符类型,可以理解为先把32313133353236313431303231363533e4b893e5b19e31333335313237变量转为字符型然后在进行字符拼接。
public class Test {
public static void main(String[] args){
int intnum = 9;
long longnum = 10L;
short shortnum = 11;
byte bytenum = 12;
float floatnum = 13F;
double doublenum = 14;
char charstr = 56; //ASCII码对应8
String str = “Zhu Cheng feng is a good boy!”;
boolean booleanstr = true;
System.out.println(“intnum is “+intnum);
System.out.println(“longnum is “+longnum);
System.out.println(“shortnum is “+shortnum);
System.out.println(“bytenum is “+bytenum);
System.out.println(“floatnum is “+floatnum);
System.out.println(“doublenum is “+doublenum);
System.out.println(“charstr is “+charstr);
System.out.println(“str is “+str);
System.out.println(“booleanstr is “+booleanstr);
}
}
2、多个变量参与运算时JAVA程序每行的执行顺序是从左到右
public class Test {
public static void main(String[] args){
int intnum = 9;
long longnum = 10L;
System.out.println(intnum+longnum+” is the result!”);
}
}
发布者:全栈程序员栈长,转载请注明出处:https://javaforall.cn/156816.html原文链接:https://javaforall.cn
扫码关注腾讯云开发者
领取腾讯云代金券
Copyright © 2013 - 2025 Tencent Cloud. All Rights Reserved. 腾讯云 版权所有
深圳市腾讯计算机系统有限公司 ICP备案/许可证号:粤B2-20090059 深公网安备号 44030502008569
腾讯云计算(北京)有限责任公司 京ICP证150476号 | 京ICP备11018762号 | 京公网安备号11010802020287
Copyright © 2013 - 2025 Tencent Cloud.
All Rights Reserved. 腾讯云 版权所有