---
title: "javap分析一行简单的运算符代码"
author: "fly0wings"
date: "2015-01-22T09:27:21Z"
tags: []
categories: ["编程语言"]
slug: "javap"
draft: false
lastmod: "2015-01-22T09:27:21Z"
id: 2178335
url: "https://fly0wing.iteye.com/blog/2178335"
---

javap分析一行简单的运算符代码，不多解释。

 

code：

```
/**
 * Created by zkai on 2015/1/21.
 */
public class Test {
    public static void main(String[] args) {

        int x = 10;
        x += x += x -= x - 2;
        System.out.println(x);

        // 等价于...
        int y = 10;
        int tmp1 = y - 2;
        int tmp2 = y - tmp1;
        int tmp3 = y + tmp2;
        int tmp4 = y + tmp3;
        y = tmp4;
        System.out.println(y);

        System.out.println(y == x);

    }
}
```

 

javap 分析：

   
![](http://dl2.iteye.com/upload/attachment/0105/4802/813e165b-5892-31c3-a514-0903b378ec7f.png)