大家好,又见面了,我是你们的朋友全栈君。
展开全部
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!”);
}
}
发布者:全栈程序员-用户IM,转载请注明出处:https://javaforall.cn/156816.html原文链接:https://javaforall.cn
【正版授权,激活自己账号】: Jetbrains全家桶Ide使用,1年售后保障,每天仅需1毛
【官方授权 正版激活】: 官方授权 正版激活 支持Jetbrains家族下所有IDE 使用个人JB账号...