qq_年少呆萌心i_0
2017-03-10 17:58
public class HelloWorld{
public static void main(String[] args) {
int age1=24;
int age2=18;
int age3=36;
int age4=27;
int sum = age1+age2+age3+age4;
int avg = sum/4;
int minus = age1-age2;
int newAge = age1++
System.out.println("年龄总和:"+sum);
System.out.println("平均年龄:"+avg);
System.out.println("年龄差值:"+minus);
System.out.println("自减后的年龄:"+newAge);
}
}
要的是自减后,你那是自增!
int newAge=age1--;
public class HelloWorld{
public static void main(String[] args) {
int age1=24;
int age2=18;
int age3=36;
int age4=27;
int sum = age1+age2+age3+age4;
int avg = sum/4;
int minus = age1-age2;
int newAge = --age1;
System.out.println("年龄总和:"+sum);
System.out.println("平均年龄:"+avg);
System.out.println("年龄差值:"+minus);
System.out.println("自减后的年龄:"+newAge);
}
}
int newAge = age1++的后面少了个分号
Java入门第一季(IDEA工具)升级版
1165175 学习 · 17581 问题
相似问题