美文网首页Java
Incremental Demo

Incremental Demo

作者: JaedenKil | 来源:发表于2020-08-17 14:32 被阅读0次
    public class IncrementalDemo {
        public static void main(String[] args) {
            int a = 1;
            int b = 1;
            int x = ++a;
            int y = b++;
            // ++a: Increase a, then use the value
            // So x = ++a: a = a + 1, x = a
            System.out.println("a = " + a + ", x = " + x);
            // b++: Use the value, then increase b
            // So y = b, b = b + 1
            System.out.println("b = " + b + ", y = " + y);
        }
    }
    
    a = 2, x = 2
    b = 2, y = 1
    

    相关文章

      网友评论

        本文标题:Incremental Demo

        本文链接:https://www.haomeiwen.com/subject/rdlqjktx.html