阳光下的大柚子
2017-09-17 20:13
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 = one +two ==>",+three);
three+=one;
System.out.println("three +=one ==>",+three);
three-=one;
System.out.println("three -=one ==>",+three);
three*=one;
System.out.println("three *=one ==>",+three);
three/=one;
System.out.println("three /=one ==>",+three);
three%=one;
System.out.println("three %=one ==>",+three);
}
}
将System.out.println("xxx",+xx);改为System.out.println("xxx"+xx);即可。(去掉逗号)
解决了,上述第二个问题是我重复定义了。谢谢大家
HelloWorld.java:9: error: variable one is already defined in method main(String[])
int one = 10 ;
^
HelloWorld.java:10: error: variable two is already defined in method main(String[])
int two = 20 ;
^
HelloWorld.java:11: error: variable three is already defined in method main(String[])
int three = 0 ;
^
3 errors
不要逗号
把打印信息中的逗号去掉,字符创拼接不需要逗号,如下:
int one = 10 ; int two = 20 ; int three = 0 ; three=one+two; System.out.println("three = one +two ==>"+three); three+=one; System.out.println("three +=one ==>"+three); three-=one; System.out.println("three -=one ==>"+three); three*=one; System.out.println("three *=one ==>"+three); three/=one; System.out.println("three /=one ==>"+three); three%=one; System.out.println("three %=one ==>"+three);
把println()方法中的逗号去掉
Java入门第一季(IDEA工具)升级版
1165172 学习 · 17581 问题
相似问题