折木奉太郎3728425
2016-07-29 21:43
public class HelloWorld{
public static void main(String[] args) {
int one = 10 ;
int two = 20 ;
int three = 0 ;
int three=one+two;
System.out.println(three);
int three+=one;
System.out.println(three);
int three-=one;
System.out.println(three);
int three*=one;
System.out.println(three);
double three/=one;
System.out.println(three);
int three%=one;
System.out.println(three);
}
}
结果编译出来的结果是:
/85/1298/Fdvt/HelloWorld.java:8: error: ';' expected
int three+=one;
^
/85/1298/Fdvt/HelloWorld.java:8: error: not a statement
int three+=one;
^
/85/1298/Fdvt/HelloWorld.java:10: error: ';' expected
int three-=one;
^
/85/1298/Fdvt/HelloWorld.java:10: error: not a statement
int three-=one;
^
/85/1298/Fdvt/HelloWorld.java:12: error: ';' expected
int three*=one;
^
/85/1298/Fdvt/HelloWorld.java:12: error: not a statement
int three*=one;
^
/85/1298/Fdvt/HelloWorld.java:14: error: ';' expected
double three/=one;
^
/85/1298/Fdvt/HelloWorld.java:14: error: not a statement
double three/=one;
^
/85/1298/Fdvt/HelloWorld.java:16: error: ';' expected
int three%=one;
^
/85/1298/Fdvt/HelloWorld.java:16: error: not a statement
int three%=one;
^
10 errors
你这叫定义多个three的参数 如果要定义不同的参数就要不同的名字 如果要参数一直运算就不要参数类型
多打了int定义变量类型一次就够了,以后就不用一直定义了
public class HelloWorld{
public static void main(String[] args) {
int one = 10 ;
int two = 20 ;
int three = 0 ;
three=one+two;
System.out.println(three);
three+=one;
System.out.println(three);
three-=one;
System.out.println(three);
three*=one;
System.out.println(three);
three/=one;
System.out.println(three);
three%=one;
System.out.println(three);
}
}
int three只能用一次,不能又int three。int表示定义一个新的变量。从这句int three=one+two;以后都不要int
Java入门第一季(IDEA工具)升级版
1165551 学习 · 17586 问题
相似问题