问答详情
源自:3-3 Java中的赋值运算符

求指教,为什么显示全是Three?

public class HelloWorld{

    public static void main(String[] args) {

   int one = 10 ;

        int two = 20 ;

        int three = 0 ;

        int three0 =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");three %= one;

        

这样对吗?为什么显示出来全是three?

提问者:curzes 2015-03-11 11:05

个回答

  • 小肠杆君
    2015-03-20 09:53:11

    因为你输出函数里的three是字符串,注意"three",表示你这里是一个字符串常量。去掉""后,就是变量了,就能显示变量three的值

  • Mr_Li_0001
    2015-03-11 11:10:45

    this is Constant,is not Variable.