幫我看看代碼有什么問題
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);
? ? ? ? System.out.println(" three+=one ==>"? +three);
? ? ? ? System.out.println(" three-=one ==>"? +three);
? ? ? ? System.out.println(" three*=one ==>"? +three);
? ? ? ? System.out.println(" three/=one ==>"? +three);
? ? ? ? System.out.println(" three%=one ==>"? +three);
}
}
2018-09-22
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.print("three += one ==> " + three);
? ? ? ? three -= one;
? ? ? ? System.out.print("three -= one ==> " + three);
? ? ? ? three *= one;
? ? ? ? System.out.print("three *= one ==> " + three);
? ? ? ? three /= one;
? ? ? ? System.out.print("three /= one ==> " + three);
? ? ? ? three %= one;
? ? ? ? System.out.print("three %= one ==> " + three);
仔細看要求。他要的結(jié)果有好幾個,而你只賦了一次值,也就是:three = one + two;
2018-09-12
System.out.println后面括號中“”里面的東西都會以原模原樣出現(xiàn)在結(jié)果中,真正輸出的值是+后面的變量的值,所以你的代碼應該是全都輸出30吧