基本语法要点


一、注释

1.1 三种注释形式

// ═══════════════════════════════════════════════════════════════════════
// 1. 单行注释:用于解释单行代码逻辑
// ═══════════════════════════════════════════════════════════════════════

int count = 0;  // 计数器初始化为0

// ═══════════════════════════════════════════════════════════════════════
// 2. 多行注释:用于解释代码块(实际开发中较少使用)
// ═══════════════════════════════════════════════════════════════════════

/*
 * 这是一个多行注释
 * 可以跨越多行
 * 通常用于临时屏蔽代码块
 */

/* 也可以写成一行 */

// ═══════════════════════════════════════════════════════════════════════
// 3. 文档注释:用于生成 JavaDoc API 文档
// ═══════════════════════════════════════════════════════════════════════

/**
 * 计算两个整数的和
 * 
 * @author  张三
 * @version 1.0
 * @since   JDK 1.8
 * @param a 第一个加数
 * @param b 第二个加数
 * @return  两数之和
 * @throws  ArithmeticException 如果结果溢出
 * @see     Math#addExact(int, int)
 */
public int add(int a, int b) {
    return a + b;
}

1.2 常用 JavaDoc 标签

<mxfile>
  <diagram id="javadoc-tags" name="常用JavaDoc标签">
    <mxGraphModel dx="1281" dy="581" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="850" pageHeight="600" math="0" shadow="0">
      <root>
        <mxCell id="0" />
        <mxCell id="1" parent="0" />
        <mxCell id="2" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=20;fontStyle=1;fontColor=#1a1a1a;" value="常用 JavaDoc 标签" vertex="1">
          <mxGeometry height="40" width="300" x="250" y="46" as="geometry" />
        </mxCell>
        <mxCell id="3" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#f5f5f5;strokeColor=#666666;strokeWidth=2;arcSize=8;" value="" vertex="1">
          <mxGeometry height="480" width="720" x="40" y="86" as="geometry" />
        </mxCell>
        <mxCell id="4" parent="1" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#1565C0;strokeColor=#1565C0;fontColor=#ffffff;fontStyle=1;fontSize=14;" value="标签" vertex="1">
          <mxGeometry height="40" width="160" x="70" y="110" as="geometry" />
        </mxCell>
        <mxCell id="5" parent="1" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#1565C0;strokeColor=#1565C0;fontColor=#ffffff;fontStyle=1;fontSize=14;" value="说明" vertex="1">
          <mxGeometry height="40" width="500" x="230" y="110" as="geometry" />
        </mxCell>
        <mxCell id="6" parent="1" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#E3F2FD;strokeColor=#90CAF9;fontColor=#1565C0;fontStyle=1;fontSize=13;fontFamily=Consolas;" value="@author" vertex="1">
          <mxGeometry height="36" width="160" x="70" y="150" as="geometry" />
        </mxCell>
        <mxCell id="7" parent="1" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#90CAF9;fontColor=#333333;fontSize=13;align=left;spacingLeft=20;" value="作者" vertex="1">
          <mxGeometry height="36" width="500" x="230" y="150" as="geometry" />
        </mxCell>
        <mxCell id="8" parent="1" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#E3F2FD;strokeColor=#90CAF9;fontColor=#1565C0;fontStyle=1;fontSize=13;fontFamily=Consolas;" value="@version" vertex="1">
          <mxGeometry height="36" width="160" x="70" y="186" as="geometry" />
        </mxCell>
        <mxCell id="9" parent="1" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#F5F5F5;strokeColor=#90CAF9;fontColor=#333333;fontSize=13;align=left;spacingLeft=20;" value="版本号" vertex="1">
          <mxGeometry height="36" width="500" x="230" y="186" as="geometry" />
        </mxCell>
        <mxCell id="10" parent="1" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#E3F2FD;strokeColor=#90CAF9;fontColor=#1565C0;fontStyle=1;fontSize=13;fontFamily=Consolas;" value="@since" vertex="1">
          <mxGeometry height="36" width="160" x="70" y="222" as="geometry" />
        </mxCell>
        <mxCell id="11" parent="1" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#90CAF9;fontColor=#333333;fontSize=13;align=left;spacingLeft=20;" value="从哪个版本开始" vertex="1">
          <mxGeometry height="36" width="500" x="230" y="222" as="geometry" />
        </mxCell>
        <mxCell id="12" parent="1" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#E3F2FD;strokeColor=#90CAF9;fontColor=#1565C0;fontStyle=1;fontSize=13;fontFamily=Consolas;" value="@param" vertex="1">
          <mxGeometry height="36" width="160" x="70" y="258" as="geometry" />
        </mxCell>
        <mxCell id="13" parent="1" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#F5F5F5;strokeColor=#90CAF9;fontColor=#333333;fontSize=13;align=left;spacingLeft=20;" value="方法参数说明" vertex="1">
          <mxGeometry height="36" width="500" x="230" y="258" as="geometry" />
        </mxCell>
        <mxCell id="14" parent="1" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#E3F2FD;strokeColor=#90CAF9;fontColor=#1565C0;fontStyle=1;fontSize=13;fontFamily=Consolas;" value="@return" vertex="1">
          <mxGeometry height="36" width="160" x="70" y="294" as="geometry" />
        </mxCell>
        <mxCell id="15" parent="1" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#90CAF9;fontColor=#333333;fontSize=13;align=left;spacingLeft=20;" value="返回值说明" vertex="1">
          <mxGeometry height="36" width="500" x="230" y="294" as="geometry" />
        </mxCell>
        <mxCell id="16" parent="1" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#E3F2FD;strokeColor=#90CAF9;fontColor=#1565C0;fontStyle=1;fontSize=13;fontFamily=Consolas;" value="@throws" vertex="1">
          <mxGeometry height="36" width="160" x="70" y="330" as="geometry" />
        </mxCell>
        <mxCell id="17" parent="1" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#F5F5F5;strokeColor=#90CAF9;fontColor=#333333;fontSize=13;align=left;spacingLeft=20;" value="可能抛出的异常" vertex="1">
          <mxGeometry height="36" width="500" x="230" y="330" as="geometry" />
        </mxCell>
        <mxCell id="18" parent="1" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#E3F2FD;strokeColor=#90CAF9;fontColor=#1565C0;fontStyle=1;fontSize=13;fontFamily=Consolas;" value="@exception" vertex="1">
          <mxGeometry height="36" width="160" x="70" y="366" as="geometry" />
        </mxCell>
        <mxCell id="19" parent="1" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#90CAF9;fontColor=#333333;fontSize=13;align=left;spacingLeft=20;" value="同 @throws" vertex="1">
          <mxGeometry height="36" width="500" x="230" y="366" as="geometry" />
        </mxCell>
        <mxCell id="20" parent="1" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#E3F2FD;strokeColor=#90CAF9;fontColor=#1565C0;fontStyle=1;fontSize=13;fontFamily=Consolas;" value="@see" vertex="1">
          <mxGeometry height="36" width="160" x="70" y="402" as="geometry" />
        </mxCell>
        <mxCell id="21" parent="1" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#F5F5F5;strokeColor=#90CAF9;fontColor=#333333;fontSize=13;align=left;spacingLeft=20;" value="参考链接" vertex="1">
          <mxGeometry height="36" width="500" x="230" y="402" as="geometry" />
        </mxCell>
        <mxCell id="22" parent="1" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#E3F2FD;strokeColor=#90CAF9;fontColor=#1565C0;fontStyle=1;fontSize=13;fontFamily=Consolas;" value="@link" vertex="1">
          <mxGeometry height="36" width="160" x="70" y="438" as="geometry" />
        </mxCell>
        <mxCell id="23" parent="1" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#90CAF9;fontColor=#333333;fontSize=13;align=left;spacingLeft=20;" value="行内链接 &lt;font face=&quot;Consolas&quot;&gt;{@link ClassName#method}&lt;/font&gt;" vertex="1">
          <mxGeometry height="36" width="500" x="230" y="438" as="geometry" />
        </mxCell>
        <mxCell id="24" parent="1" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#E3F2FD;strokeColor=#90CAF9;fontColor=#1565C0;fontStyle=1;fontSize=13;fontFamily=Consolas;" value="@code" vertex="1">
          <mxGeometry height="36" width="160" x="70" y="474" as="geometry" />
        </mxCell>
        <mxCell id="25" parent="1" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#F5F5F5;strokeColor=#90CAF9;fontColor=#333333;fontSize=13;align=left;spacingLeft=20;" value="行内代码 &lt;font face=&quot;Consolas&quot;&gt;{@code example}&lt;/font&gt;" vertex="1">
          <mxGeometry height="36" width="500" x="230" y="474" as="geometry" />
        </mxCell>
        <mxCell id="26" parent="1" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#E3F2FD;strokeColor=#90CAF9;fontColor=#1565C0;fontStyle=1;fontSize=13;fontFamily=Consolas;" value="@deprecated" vertex="1">
          <mxGeometry height="36" width="160" x="70" y="510" as="geometry" />
        </mxCell>
        <mxCell id="27" parent="1" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#90CAF9;fontColor=#333333;fontSize=13;align=left;spacingLeft=20;" value="标记为已过时" vertex="1">
          <mxGeometry height="36" width="500" x="230" y="510" as="geometry" />
        </mxCell>
      </root>
    </mxGraphModel>
  </diagram>
</mxfile>
# 生成 JavaDoc 文档
javadoc -d docs -encoding UTF-8 -charset UTF-8 *.java

# 生成的文档结构
docs/
├── index.html          # 首页
├── allclasses.html     # 所有类列表
├── package-summary.html
└── com/
    └── example/
        └── MyClass.html

1.3 注释的本质

<mxfile>
  <diagram id="comment-compilation" name="注释的编译过程">
    <mxGraphModel dx="900" dy="600" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="850" pageHeight="500">
      <root>
        <mxCell id="0" />
        <mxCell id="1" parent="0" />
        <mxCell id="2" value="" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#f5f5f5;strokeColor=#666666;strokeWidth=2;arcSize=6;" vertex="1" parent="1">
          <mxGeometry x="40" y="30" width="770" height="400" as="geometry" />
        </mxCell>
        <mxCell id="3" value="注释的编译过程" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=22;fontStyle=1;fontColor=#1a1a1a;" vertex="1" parent="1">
          <mxGeometry x="280" y="50" width="290" height="40" as="geometry" />
        </mxCell>
        <mxCell id="4" value="源代码 (.java)" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=14;fontStyle=1;fontColor=#1565C0;" vertex="1" parent="1">
          <mxGeometry x="100" y="110" width="120" height="30" as="geometry" />
        </mxCell>
        <mxCell id="5" value="字节码 (.class)" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=14;fontStyle=1;fontColor=#2E7D32;" vertex="1" parent="1">
          <mxGeometry x="570" y="110" width="120" height="30" as="geometry" />
        </mxCell>
        <mxCell id="6" value="" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#E3F2FD;strokeColor=#1565C0;strokeWidth=2;arcSize=8;" vertex="1" parent="1">
          <mxGeometry x="70" y="145" width="250" height="180" as="geometry" />
        </mxCell>
        <mxCell id="7" value="&lt;div style=&quot;text-align: left;&quot;&gt;&lt;font face=&quot;Consolas&quot; color=&quot;#6a9955&quot;&gt;// 这是注释&lt;/font&gt;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;font face=&quot;Consolas&quot;&gt;&lt;font color=&quot;#0000ff&quot;&gt;public class&lt;/font&gt; &lt;font color=&quot;#267f99&quot;&gt;Demo&lt;/font&gt; {&lt;/font&gt;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;font face=&quot;Consolas&quot; color=&quot;#6a9955&quot;&gt;  /* 多行注释 */&lt;/font&gt;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;font face=&quot;Consolas&quot;&gt;  &lt;font color=&quot;#0000ff&quot;&gt;int&lt;/font&gt; x = &lt;font color=&quot;#098658&quot;&gt;1&lt;/font&gt;;&lt;/font&gt;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;font face=&quot;Consolas&quot;&gt;}&lt;/font&gt;&lt;/div&gt;" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=14;fontColor=#333333;spacing=10;" vertex="1" parent="1">
          <mxGeometry x="85" y="165" width="220" height="140" as="geometry" />
        </mxCell>
        <mxCell id="8" value="" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#E8F5E9;strokeColor=#2E7D32;strokeWidth=2;arcSize=8;" vertex="1" parent="1">
          <mxGeometry x="530" y="145" width="250" height="180" as="geometry" />
        </mxCell>
        <mxCell id="9" value="&lt;div style=&quot;text-align: left;&quot;&gt;&lt;br&gt;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;font face=&quot;Consolas&quot;&gt;&lt;font color=&quot;#0000ff&quot;&gt;public class&lt;/font&gt; &lt;font color=&quot;#267f99&quot;&gt;Demo&lt;/font&gt; {&lt;/font&gt;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;font face=&quot;Consolas&quot; color=&quot;#9e9e9e&quot;&gt;  &lt;i&gt;// 注释被移除&lt;/i&gt;&lt;/font&gt;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;font face=&quot;Consolas&quot;&gt;  &lt;font color=&quot;#0000ff&quot;&gt;int&lt;/font&gt; x = &lt;font color=&quot;#098658&quot;&gt;1&lt;/font&gt;;&lt;/font&gt;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;font face=&quot;Consolas&quot;&gt;}&lt;/font&gt;&lt;/div&gt;" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=14;fontColor=#333333;spacing=10;" vertex="1" parent="1">
          <mxGeometry x="545" y="165" width="220" height="140" as="geometry" />
        </mxCell>
        <mxCell id="10" value="" style="endArrow=blockThin;html=1;rounded=0;strokeWidth=3;strokeColor=#FF6D00;endFill=1;startSize=8;endSize=10;" edge="1" parent="1">
          <mxGeometry width="50" height="50" relative="1" as="geometry">
            <mxPoint x="340" y="235" as="sourcePoint" />
            <mxPoint x="510" y="235" as="targetPoint" />
          </mxGeometry>
        </mxCell>
        <mxCell id="11" value="javac" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=16;fontStyle=1;fontColor=#FF6D00;fontFamily=Consolas;" vertex="1" parent="1">
          <mxGeometry x="390" y="195" width="70" height="30" as="geometry" />
        </mxCell>
        <mxCell id="12" value="编译" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=13;fontColor=#666666;" vertex="1" parent="1">
          <mxGeometry x="395" y="245" width="60" height="25" as="geometry" />
        </mxCell>
        <mxCell id="13" value="" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#FFF3E0;strokeColor=#FF6D00;strokeWidth=2;arcSize=12;" vertex="1" parent="1">
          <mxGeometry x="70" y="350" width="710" height="60" as="geometry" />
        </mxCell>
        <mxCell id="14" value="⚠️" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=24;" vertex="1" parent="1">
          <mxGeometry x="85" y="358" width="40" height="44" as="geometry" />
        </mxCell>
        <mxCell id="15" value="编译器在编译阶段会移除所有注释,字节码中不包含注释信息" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=15;fontColor=#E65100;fontStyle=0;" vertex="1" parent="1">
          <mxGeometry x="130" y="358" width="620" height="44" as="geometry" />
        </mxCell>
        <mxCell id="16" value=".java" style="ellipse;whiteSpace=wrap;html=1;fillColor=#1565C0;strokeColor=#0D47A1;fontColor=#ffffff;fontSize=11;fontStyle=1;" vertex="1" parent="1">
          <mxGeometry x="270" y="285" width="50" height="30" as="geometry" />
        </mxCell>
        <mxCell id="17" value=".class" style="ellipse;whiteSpace=wrap;html=1;fillColor=#2E7D32;strokeColor=#1B5E20;fontColor=#ffffff;fontSize=11;fontStyle=1;" vertex="1" parent="1">
          <mxGeometry x="530" y="285" width="50" height="30" as="geometry" />
        </mxCell>
      </root>
    </mxGraphModel>
  </diagram>
</mxfile>

1.4 注释最佳实践

// ════════════════════════════════════════════════════════════════════════
// ❌ 不好的写法:注释说明显而易见的事情
// ════════════════════════════════════════════════════════════════════════

// 设置 age 为 25
int age = 25;

// 如果 age 大于 18
if (age > 18) {
    // 打印成年
    System.out.println("成年");
}

// ════════════════════════════════════════════════════════════════════════
// ❌ 不好的写法:注释解释复杂逻辑
// ════════════════════════════════════════════════════════════════════════

// 检查员工是否有资格获得全部福利
// 条件:按小时计费 且 年龄大于65岁
if ((employee.flags & HOURLY_FLAG) && (employee.age > 65)) {
    // ...
}

// ════════════════════════════════════════════════════════════════════════
// ✅ 好的写法:用清晰的命名代替注释
// ════════════════════════════════════════════════════════════════════════

if (employee.isEligibleForFullBenefits()) {
    // ...
}

// ════════════════════════════════════════════════════════════════════════
// ✅ 好的写法:注释解释 "为什么" 而非 "是什么"
// ════════════════════════════════════════════════════════════════════════

// 使用 insertion sort 而非 quicksort,因为数据量小于 10 且几乎有序
// 参考性能测试结果:benchmark_2024.md
Arrays.sort(smallArray);

// 保留 2 的缓冲空间,避免频繁扩容
// 根据历史数据,99% 的请求不超过 capacity + 2
List<Item> items = new ArrayList<>(capacity + 2);
<mxfile>
  <diagram id="clean-code-comments" name="注释原则">
    <mxGraphModel dx="900" dy="700" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="850" pageHeight="680">
      <root>
        <mxCell id="0" />
        <mxCell id="1" parent="0" />
        <mxCell id="2" value="" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#FAFAFA;strokeColor=#424242;strokeWidth=2;arcSize=4;" vertex="1" parent="1">
          <mxGeometry x="30" y="20" width="790" height="640" as="geometry" />
        </mxCell>
        <mxCell id="3" value="注释原则" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=24;fontStyle=1;fontColor=#1a1a1a;" vertex="1" parent="1">
          <mxGeometry x="300" y="40" width="150" height="40" as="geometry" />
        </mxCell>
        <mxCell id="4" value="来自《Clean Code》" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=13;fontColor=#757575;fontStyle=2;" vertex="1" parent="1">
          <mxGeometry x="450" y="45" width="140" height="30" as="geometry" />
        </mxCell>
        <mxCell id="5" value="1" style="ellipse;whiteSpace=wrap;html=1;fillColor=#1565C0;strokeColor=#0D47A1;fontColor=#ffffff;fontSize=16;fontStyle=1;" vertex="1" parent="1">
          <mxGeometry x="60" y="100" width="36" height="36" as="geometry" />
        </mxCell>
        <mxCell id="6" value="好代码自解释" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=16;fontStyle=1;fontColor=#1565C0;" vertex="1" parent="1">
          <mxGeometry x="110" y="100" width="130" height="36" as="geometry" />
        </mxCell>
        <mxCell id="7" value="代码本身就是最好的文档" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=14;fontColor=#424242;" vertex="1" parent="1">
          <mxGeometry x="250" y="100" width="500" height="36" as="geometry" />
        </mxCell>
        <mxCell id="8" value="" style="line;strokeWidth=1;html=1;strokeColor=#E0E0E0;" vertex="1" parent="1">
          <mxGeometry x="60" y="145" width="720" height="1" as="geometry" />
        </mxCell>
        <mxCell id="9" value="2" style="ellipse;whiteSpace=wrap;html=1;fillColor=#7B1FA2;strokeColor=#6A1B9A;fontColor=#ffffff;fontSize=16;fontStyle=1;" vertex="1" parent="1">
          <mxGeometry x="60" y="160" width="36" height="36" as="geometry" />
        </mxCell>
        <mxCell id="10" value="注释不是坏代码的借口" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=16;fontStyle=1;fontColor=#7B1FA2;" vertex="1" parent="1">
          <mxGeometry x="110" y="160" width="200" height="36" as="geometry" />
        </mxCell>
        <mxCell id="11" value="与其写注释解释烂代码,不如重构" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=14;fontColor=#424242;" vertex="1" parent="1">
          <mxGeometry x="320" y="160" width="430" height="36" as="geometry" />
        </mxCell>
        <mxCell id="12" value="" style="line;strokeWidth=1;html=1;strokeColor=#E0E0E0;" vertex="1" parent="1">
          <mxGeometry x="60" y="205" width="720" height="1" as="geometry" />
        </mxCell>
        <mxCell id="13" value="3" style="ellipse;whiteSpace=wrap;html=1;fillColor=#F57C00;strokeColor=#EF6C00;fontColor=#ffffff;fontSize=16;fontStyle=1;" vertex="1" parent="1">
          <mxGeometry x="60" y="220" width="36" height="36" as="geometry" />
        </mxCell>
        <mxCell id="14" value="注释会过时" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=16;fontStyle=1;fontColor=#F57C00;" vertex="1" parent="1">
          <mxGeometry x="110" y="220" width="110" height="36" as="geometry" />
        </mxCell>
        <mxCell id="15" value="代码变了注释没变,注释就成了谎言" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=14;fontColor=#424242;" vertex="1" parent="1">
          <mxGeometry x="230" y="220" width="520" height="36" as="geometry" />
        </mxCell>
        <mxCell id="16" value="" style="line;strokeWidth=1;html=1;strokeColor=#E0E0E0;" vertex="1" parent="1">
          <mxGeometry x="60" y="265" width="720" height="1" as="geometry" />
        </mxCell>
        <mxCell id="17" value="4" style="ellipse;whiteSpace=wrap;html=1;fillColor=#2E7D32;strokeColor=#1B5E20;fontColor=#ffffff;fontSize=16;fontStyle=1;" vertex="1" parent="1">
          <mxGeometry x="60" y="285" width="36" height="36" as="geometry" />
        </mxCell>
        <mxCell id="18" value="有价值的注释" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=16;fontStyle=1;fontColor=#2E7D32;" vertex="1" parent="1">
          <mxGeometry x="110" y="285" width="130" height="36" as="geometry" />
        </mxCell>
        <mxCell id="19" value="" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#E8F5E9;strokeColor=#A5D6A7;strokeWidth=2;arcSize=10;" vertex="1" parent="1">
          <mxGeometry x="80" y="330" width="700" height="120" as="geometry" />
        </mxCell>
        <mxCell id="20" value="" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#66BB6A;arcSize=12;" vertex="1" parent="1">
          <mxGeometry x="100" y="345" width="150" height="90" as="geometry" />
        </mxCell>
        <mxCell id="21" value="✓" style="text;html=1;strokeColor=none;fillColor=#2E7D32;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=1;fontSize=14;fontColor=#ffffff;fontStyle=1;" vertex="1" parent="1">
          <mxGeometry x="110" y="352" width="24" height="24" as="geometry" />
        </mxCell>
        <mxCell id="22" value="解释意图 (Why)" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=13;fontColor=#2E7D32;fontStyle=1;" vertex="1" parent="1">
          <mxGeometry x="140" y="350" width="110" height="28" as="geometry" />
        </mxCell>
        <mxCell id="23" value="说明为什么这样做" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=12;fontColor=#616161;" vertex="1" parent="1">
          <mxGeometry x="110" y="378" width="130" height="50" as="geometry" />
        </mxCell>
        <mxCell id="24" value="" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#66BB6A;arcSize=12;" vertex="1" parent="1">
          <mxGeometry x="265" y="345" width="150" height="90" as="geometry" />
        </mxCell>
        <mxCell id="25" value="✓" style="text;html=1;strokeColor=none;fillColor=#2E7D32;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=1;fontSize=14;fontColor=#ffffff;fontStyle=1;" vertex="1" parent="1">
          <mxGeometry x="275" y="352" width="24" height="24" as="geometry" />
        </mxCell>
        <mxCell id="26" value="警告后果" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=13;fontColor=#2E7D32;fontStyle=1;" vertex="1" parent="1">
          <mxGeometry x="305" y="350" width="100" height="28" as="geometry" />
        </mxCell>
        <mxCell id="27" value="提醒潜在风险" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=12;fontColor=#616161;" vertex="1" parent="1">
          <mxGeometry x="275" y="378" width="130" height="50" as="geometry" />
        </mxCell>
        <mxCell id="28" value="" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#66BB6A;arcSize=12;" vertex="1" parent="1">
          <mxGeometry x="430" y="345" width="150" height="90" as="geometry" />
        </mxCell>
        <mxCell id="29" value="✓" style="text;html=1;strokeColor=none;fillColor=#2E7D32;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=1;fontSize=14;fontColor=#ffffff;fontStyle=1;" vertex="1" parent="1">
          <mxGeometry x="440" y="352" width="24" height="24" as="geometry" />
        </mxCell>
        <mxCell id="30" value="TODO 标记" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=13;fontColor=#2E7D32;fontStyle=1;" vertex="1" parent="1">
          <mxGeometry x="470" y="350" width="100" height="28" as="geometry" />
        </mxCell>
        <mxCell id="31" value="待办事项提醒" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=12;fontColor=#616161;" vertex="1" parent="1">
          <mxGeometry x="440" y="378" width="130" height="50" as="geometry" />
        </mxCell>
        <mxCell id="32" value="" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#66BB6A;arcSize=12;" vertex="1" parent="1">
          <mxGeometry x="595" y="345" width="165" height="90" as="geometry" />
        </mxCell>
        <mxCell id="33" value="✓" style="text;html=1;strokeColor=none;fillColor=#2E7D32;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=1;fontSize=14;fontColor=#ffffff;fontStyle=1;" vertex="1" parent="1">
          <mxGeometry x="605" y="352" width="24" height="24" as="geometry" />
        </mxCell>
        <mxCell id="34" value="公共 API 文档" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=13;fontColor=#2E7D32;fontStyle=1;" vertex="1" parent="1">
          <mxGeometry x="635" y="350" width="115" height="28" as="geometry" />
        </mxCell>
        <mxCell id="35" value="JavaDoc 注释" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=12;fontColor=#616161;" vertex="1" parent="1">
          <mxGeometry x="605" y="378" width="145" height="50" as="geometry" />
        </mxCell>
        <mxCell id="36" value="5" style="ellipse;whiteSpace=wrap;html=1;fillColor=#C62828;strokeColor=#B71C1C;fontColor=#ffffff;fontSize=16;fontStyle=1;" vertex="1" parent="1">
          <mxGeometry x="60" y="470" width="36" height="36" as="geometry" />
        </mxCell>
        <mxCell id="37" value="无价值的注释" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=16;fontStyle=1;fontColor=#C62828;" vertex="1" parent="1">
          <mxGeometry x="110" y="470" width="130" height="36" as="geometry" />
        </mxCell>
        <mxCell id="38" value="" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#FFEBEE;strokeColor=#EF9A9A;strokeWidth=2;arcSize=10;" vertex="1" parent="1">
          <mxGeometry x="80" y="515" width="700" height="120" as="geometry" />
        </mxCell>
        <mxCell id="39" value="" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#EF5350;arcSize=12;" vertex="1" parent="1">
          <mxGeometry x="100" y="530" width="150" height="90" as="geometry" />
        </mxCell>
        <mxCell id="40" value="✗" style="text;html=1;strokeColor=none;fillColor=#C62828;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=1;fontSize=14;fontColor=#ffffff;fontStyle=1;" vertex="1" parent="1">
          <mxGeometry x="110" y="537" width="24" height="24" as="geometry" />
        </mxCell>
        <mxCell id="41" value="重复代码内容" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=13;fontColor=#C62828;fontStyle=1;" vertex="1" parent="1">
          <mxGeometry x="140" y="535" width="110" height="28" as="geometry" />
        </mxCell>
        <mxCell id="42" value="// i 加 1&lt;br&gt;i++;" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=11;fontColor=#757575;fontFamily=Consolas;" vertex="1" parent="1">
          <mxGeometry x="110" y="565" width="130" height="50" as="geometry" />
        </mxCell>
        <mxCell id="43" value="" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#EF5350;arcSize=12;" vertex="1" parent="1">
          <mxGeometry x="265" y="530" width="150" height="90" as="geometry" />
        </mxCell>
        <mxCell id="44" value="✗" style="text;html=1;strokeColor=none;fillColor=#C62828;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=1;fontSize=14;fontColor=#ffffff;fontStyle=1;" vertex="1" parent="1">
          <mxGeometry x="275" y="537" width="24" height="24" as="geometry" />
        </mxCell>
        <mxCell id="45" value="日志式注释" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=13;fontColor=#C62828;fontStyle=1;" vertex="1" parent="1">
          <mxGeometry x="305" y="535" width="100" height="28" as="geometry" />
        </mxCell>
        <mxCell id="46" value="修改记录应用 Git" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=11;fontColor=#757575;" vertex="1" parent="1">
          <mxGeometry x="275" y="565" width="130" height="50" as="geometry" />
        </mxCell>
        <mxCell id="47" value="" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#EF5350;arcSize=12;" vertex="1" parent="1">
          <mxGeometry x="430" y="530" width="150" height="90" as="geometry" />
        </mxCell>
        <mxCell id="48" value="✗" style="text;html=1;strokeColor=none;fillColor=#C62828;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=1;fontSize=14;fontColor=#ffffff;fontStyle=1;" vertex="1" parent="1">
          <mxGeometry x="440" y="537" width="24" height="24" as="geometry" />
        </mxCell>
        <mxCell id="49" value="注释掉的代码" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=13;fontColor=#C62828;fontStyle=1;" vertex="1" parent="1">
          <mxGeometry x="470" y="535" width="110" height="28" as="geometry" />
        </mxCell>
        <mxCell id="50" value="用版本控制管理" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=11;fontColor=#757575;" vertex="1" parent="1">
          <mxGeometry x="440" y="565" width="130" height="50" as="geometry" />
        </mxCell>
        <mxCell id="51" value="" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#EF5350;arcSize=12;" vertex="1" parent="1">
          <mxGeometry x="595" y="530" width="165" height="90" as="geometry" />
        </mxCell>
        <mxCell id="52" value="✗" style="text;html=1;strokeColor=none;fillColor=#C62828;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=1;fontSize=14;fontColor=#ffffff;fontStyle=1;" vertex="1" parent="1">
          <mxGeometry x="605" y="537" width="24" height="24" as="geometry" />
        </mxCell>
        <mxCell id="53" value="位置标记" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=13;fontColor=#C62828;fontStyle=1;" vertex="1" parent="1">
          <mxGeometry x="635" y="535" width="115" height="28" as="geometry" />
        </mxCell>
        <mxCell id="54" value="//// END ////" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=11;fontColor=#757575;fontFamily=Consolas;" vertex="1" parent="1">
          <mxGeometry x="605" y="565" width="145" height="50" as="geometry" />
        </mxCell>
      </root>
    </mxGraphModel>
  </diagram>
</mxfile>

二、标识符与关键字

2.1 标识符

<mxfile>
  <diagram id="identifier-definition" name="标识符定义">
    <mxGraphModel dx="900" dy="680" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="850" pageHeight="650">
      <root>
        <mxCell id="0" />
        <mxCell id="1" parent="0" />
        <mxCell id="2" value="" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#FAFAFA;strokeColor=#424242;strokeWidth=2;arcSize=4;" vertex="1" parent="1">
          <mxGeometry x="30" y="20" width="790" height="600" as="geometry" />
        </mxCell>
        <mxCell id="3" value="标识符定义" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=26;fontStyle=1;fontColor=#1a1a1a;" vertex="1" parent="1">
          <mxGeometry x="320" y="45" width="210" height="45" as="geometry" />
        </mxCell>
        <mxCell id="4" value="" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#E3F2FD;strokeColor=#1565C0;strokeWidth=2;arcSize=8;" vertex="1" parent="1">
          <mxGeometry x="60" y="110" width="730" height="70" as="geometry" />
        </mxCell>
        <mxCell id="5" value="📝" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=28;" vertex="1" parent="1">
          <mxGeometry x="80" y="125" width="50" height="40" as="geometry" />
        </mxCell>
        <mxCell id="6" value="标识符 (Identifier)" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=18;fontStyle=1;fontColor=#1565C0;" vertex="1" parent="1">
          <mxGeometry x="135" y="120" width="180" height="30" as="geometry" />
        </mxCell>
        <mxCell id="7" value="程序中用于命名的符号" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=16;fontColor=#424242;" vertex="1" parent="1">
          <mxGeometry x="135" y="148" width="550" height="26" as="geometry" />
        </mxCell>
        <mxCell id="8" value="可命名的元素" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=18;fontStyle=1;fontColor=#2E7D32;" vertex="1" parent="1">
          <mxGeometry x="60" y="200" width="150" height="35" as="geometry" />
        </mxCell>
        <mxCell id="9" value="" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#E8F5E9;strokeColor=#A5D6A7;strokeWidth=2;arcSize=6;" vertex="1" parent="1">
          <mxGeometry x="60" y="245" width="355" height="350" as="geometry" />
        </mxCell>
        <mxCell id="10" value="" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#FFF3E0;strokeColor=#FFCC80;strokeWidth=2;arcSize=6;" vertex="1" parent="1">
          <mxGeometry x="435" y="245" width="355" height="350" as="geometry" />
        </mxCell>
        <mxCell id="11" value="" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#66BB6A;arcSize=10;" vertex="1" parent="1">
          <mxGeometry x="80" y="265" width="315" height="50" as="geometry" />
        </mxCell>
        <mxCell id="12" value="类名" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#2E7D32;strokeColor=#1B5E20;fontColor=#ffffff;fontSize=13;fontStyle=1;" vertex="1" parent="1">
          <mxGeometry x="90" y="275" width="60" height="30" as="geometry" />
        </mxCell>
        <mxCell id="13" value="class UserService" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=13;fontColor=#424242;fontFamily=Consolas;" vertex="1" parent="1">
          <mxGeometry x="165" y="275" width="220" height="30" as="geometry" />
        </mxCell>
        <mxCell id="14" value="" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#66BB6A;arcSize=10;" vertex="1" parent="1">
          <mxGeometry x="80" y="325" width="315" height="50" as="geometry" />
        </mxCell>
        <mxCell id="15" value="接口名" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#43A047;strokeColor=#2E7D32;fontColor=#ffffff;fontSize=13;fontStyle=1;" vertex="1" parent="1">
          <mxGeometry x="90" y="335" width="60" height="30" as="geometry" />
        </mxCell>
        <mxCell id="16" value="interface Runnable" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=13;fontColor=#424242;fontFamily=Consolas;" vertex="1" parent="1">
          <mxGeometry x="165" y="335" width="220" height="30" as="geometry" />
        </mxCell>
        <mxCell id="17" value="" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#66BB6A;arcSize=10;" vertex="1" parent="1">
          <mxGeometry x="80" y="385" width="315" height="50" as="geometry" />
        </mxCell>
        <mxCell id="18" value="方法名" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#66BB6A;strokeColor=#43A047;fontColor=#ffffff;fontSize=13;fontStyle=1;" vertex="1" parent="1">
          <mxGeometry x="90" y="395" width="60" height="30" as="geometry" />
        </mxCell>
        <mxCell id="19" value="void calculateTotal()" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=13;fontColor=#424242;fontFamily=Consolas;" vertex="1" parent="1">
          <mxGeometry x="165" y="395" width="220" height="30" as="geometry" />
        </mxCell>
        <mxCell id="20" value="" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#66BB6A;arcSize=10;" vertex="1" parent="1">
          <mxGeometry x="80" y="445" width="315" height="50" as="geometry" />
        </mxCell>
        <mxCell id="21" value="变量名" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#81C784;strokeColor=#66BB6A;fontColor=#ffffff;fontSize=13;fontStyle=1;" vertex="1" parent="1">
          <mxGeometry x="90" y="455" width="60" height="30" as="geometry" />
        </mxCell>
        <mxCell id="22" value="int itemCount" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=13;fontColor=#424242;fontFamily=Consolas;" vertex="1" parent="1">
          <mxGeometry x="165" y="455" width="220" height="30" as="geometry" />
        </mxCell>
        <mxCell id="23" value="" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#FFCC80;arcSize=10;" vertex="1" parent="1">
          <mxGeometry x="455" y="265" width="315" height="50" as="geometry" />
        </mxCell>
        <mxCell id="24" value="常量名" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#EF6C00;strokeColor=#E65100;fontColor=#ffffff;fontSize=13;fontStyle=1;" vertex="1" parent="1">
          <mxGeometry x="465" y="275" width="60" height="30" as="geometry" />
        </mxCell>
        <mxCell id="25" value="static final int MAX_SIZE" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=13;fontColor=#424242;fontFamily=Consolas;" vertex="1" parent="1">
          <mxGeometry x="540" y="275" width="220" height="30" as="geometry" />
        </mxCell>
        <mxCell id="26" value="" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#FFCC80;arcSize=10;" vertex="1" parent="1">
          <mxGeometry x="455" y="325" width="315" height="50" as="geometry" />
        </mxCell>
        <mxCell id="27" value="包名" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#F57C00;strokeColor=#EF6C00;fontColor=#ffffff;fontSize=13;fontStyle=1;" vertex="1" parent="1">
          <mxGeometry x="465" y="335" width="60" height="30" as="geometry" />
        </mxCell>
        <mxCell id="28" value="package com.example.demo" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=13;fontColor=#424242;fontFamily=Consolas;" vertex="1" parent="1">
          <mxGeometry x="540" y="335" width="220" height="30" as="geometry" />
        </mxCell>
        <mxCell id="29" value="" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#FFCC80;arcSize=10;" vertex="1" parent="1">
          <mxGeometry x="455" y="385" width="315" height="50" as="geometry" />
        </mxCell>
        <mxCell id="30" value="参数名" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#FFA726;strokeColor=#F57C00;fontColor=#ffffff;fontSize=13;fontStyle=1;" vertex="1" parent="1">
          <mxGeometry x="465" y="395" width="60" height="30" as="geometry" />
        </mxCell>
        <mxCell id="31" value="void setName(String name)" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=13;fontColor=#424242;fontFamily=Consolas;" vertex="1" parent="1">
          <mxGeometry x="540" y="395" width="220" height="30" as="geometry" />
        </mxCell>
        <mxCell id="32" value="" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#FFCC80;arcSize=10;" vertex="1" parent="1">
          <mxGeometry x="455" y="445" width="315" height="50" as="geometry" />
        </mxCell>
        <mxCell id="33" value="枚举名" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#FFB74D;strokeColor=#FFA726;fontColor=#ffffff;fontSize=13;fontStyle=1;" vertex="1" parent="1">
          <mxGeometry x="465" y="455" width="60" height="30" as="geometry" />
        </mxCell>
        <mxCell id="34" value="enum Color { RED, GREEN }" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=13;fontColor=#424242;fontFamily=Consolas;" vertex="1" parent="1">
          <mxGeometry x="540" y="455" width="220" height="30" as="geometry" />
        </mxCell>
        <mxCell id="35" value="" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#66BB6A;arcSize=10;" vertex="1" parent="1">
          <mxGeometry x="80" y="505" width="315" height="70" as="geometry" />
        </mxCell>
        <mxCell id="36" value="泛型名" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#A5D6A7;strokeColor=#81C784;fontColor=#1B5E20;fontSize=13;fontStyle=1;" vertex="1" parent="1">
          <mxGeometry x="90" y="525" width="60" height="30" as="geometry" />
        </mxCell>
        <mxCell id="37" value="class Box&lt;T&gt; { T value; }" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=13;fontColor=#424242;fontFamily=Consolas;" vertex="1" parent="1">
          <mxGeometry x="165" y="525" width="220" height="30" as="geometry" />
        </mxCell>
        <mxCell id="38" value="" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#FFCC80;arcSize=10;" vertex="1" parent="1">
          <mxGeometry x="455" y="505" width="315" height="70" as="geometry" />
        </mxCell>
        <mxCell id="39" value="注解名" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#FFCC80;strokeColor=#FFB74D;fontColor=#E65100;fontSize=13;fontStyle=1;" vertex="1" parent="1">
          <mxGeometry x="465" y="525" width="60" height="30" as="geometry" />
        </mxCell>
        <mxCell id="40" value="@interface MyAnnotation" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=13;fontColor=#424242;fontFamily=Consolas;" vertex="1" parent="1">
          <mxGeometry x="540" y="525" width="220" height="30" as="geometry" />
        </mxCell>
      </root>
    </mxGraphModel>
  </diagram>
</mxfile>

标识符命名规则

<mxfile>
  <diagram id="identifier-naming-rules" name="标识符命名规则">
    <mxGraphModel dx="900" dy="700" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="850" pageHeight="720">
      <root>
        <mxCell id="0" />
        <mxCell id="1" parent="0" />
        <mxCell id="2" value="" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#FAFAFA;strokeColor=#424242;strokeWidth=2;arcSize=4;" vertex="1" parent="1">
          <mxGeometry x="30" y="20" width="790" height="680" as="geometry" />
        </mxCell>
        <mxCell id="3" value="标识符命名规则" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=26;fontStyle=1;fontColor=#1a1a1a;" vertex="1" parent="1">
          <mxGeometry x="290" y="40" width="270" height="45" as="geometry" />
        </mxCell>
        <mxCell id="4" value="⚠️ 硬性规则" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=18;fontStyle=1;fontColor=#C62828;" vertex="1" parent="1">
          <mxGeometry x="60" y="100" width="140" height="35" as="geometry" />
        </mxCell>
        <mxCell id="5" value="违反会编译错误" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=13;fontColor=#757575;fontStyle=2;" vertex="1" parent="1">
          <mxGeometry x="200" y="100" width="120" height="35" as="geometry" />
        </mxCell>
        <mxCell id="6" value="" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#FFEBEE;strokeColor=#EF9A9A;strokeWidth=2;arcSize=6;" vertex="1" parent="1">
          <mxGeometry x="60" y="145" width="710" height="200" as="geometry" />
        </mxCell>
        <mxCell id="7" value="" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#EF5350;arcSize=10;" vertex="1" parent="1">
          <mxGeometry x="80" y="165" width="330" height="60" as="geometry" />
        </mxCell>
        <mxCell id="8" value="1" style="ellipse;whiteSpace=wrap;html=1;fillColor=#C62828;strokeColor=#B71C1C;fontColor=#ffffff;fontSize=16;fontStyle=1;" vertex="1" parent="1">
          <mxGeometry x="95" y="177" width="36" height="36" as="geometry" />
        </mxCell>
        <mxCell id="9" value="由字母、数字、下划线 _ 、美元符 $ 组成" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=14;fontColor=#424242;" vertex="1" parent="1">
          <mxGeometry x="140" y="177" width="260" height="36" as="geometry" />
        </mxCell>
        <mxCell id="10" value="" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#EF5350;arcSize=10;" vertex="1" parent="1">
          <mxGeometry x="425" y="165" width="330" height="60" as="geometry" />
        </mxCell>
        <mxCell id="11" value="2" style="ellipse;whiteSpace=wrap;html=1;fillColor=#C62828;strokeColor=#B71C1C;fontColor=#ffffff;fontSize=16;fontStyle=1;" vertex="1" parent="1">
          <mxGeometry x="440" y="177" width="36" height="36" as="geometry" />
        </mxCell>
        <mxCell id="12" value="不能以数字开头" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=14;fontColor=#424242;" vertex="1" parent="1">
          <mxGeometry x="485" y="177" width="260" height="36" as="geometry" />
        </mxCell>
        <mxCell id="13" value="" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#EF5350;arcSize=10;" vertex="1" parent="1">
          <mxGeometry x="80" y="240" width="330" height="60" as="geometry" />
        </mxCell>
        <mxCell id="14" value="3" style="ellipse;whiteSpace=wrap;html=1;fillColor=#C62828;strokeColor=#B71C1C;fontColor=#ffffff;fontSize=16;fontStyle=1;" vertex="1" parent="1">
          <mxGeometry x="95" y="252" width="36" height="36" as="geometry" />
        </mxCell>
        <mxCell id="15" value="不能是 Java 关键字或保留字" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=14;fontColor=#424242;" vertex="1" parent="1">
          <mxGeometry x="140" y="252" width="260" height="36" as="geometry" />
        </mxCell>
        <mxCell id="16" value="" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#EF5350;arcSize=10;" vertex="1" parent="1">
          <mxGeometry x="425" y="240" width="330" height="60" as="geometry" />
        </mxCell>
        <mxCell id="17" value="4" style="ellipse;whiteSpace=wrap;html=1;fillColor=#C62828;strokeColor=#B71C1C;fontColor=#ffffff;fontSize=16;fontStyle=1;" vertex="1" parent="1">
          <mxGeometry x="440" y="252" width="36" height="36" as="geometry" />
        </mxCell>
        <mxCell id="18" value="区分大小写 (Name ≠ name)" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=14;fontColor=#424242;" vertex="1" parent="1">
          <mxGeometry x="485" y="252" width="260" height="36" as="geometry" />
        </mxCell>
        <mxCell id="19" value="" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#E8F5E9;strokeColor=#A5D6A7;strokeWidth=2;arcSize=6;" vertex="1" parent="1">
          <mxGeometry x="60" y="370" width="330" height="310" as="geometry" />
        </mxCell>
        <mxCell id="20" value="✅ 合法标识符" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=18;fontStyle=1;fontColor=#2E7D32;" vertex="1" parent="1">
          <mxGeometry x="60" y="380" width="330" height="35" as="geometry" />
        </mxCell>
        <mxCell id="21" value="" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#66BB6A;arcSize=10;" vertex="1" parent="1">
          <mxGeometry x="80" y="425" width="290" height="40" as="geometry" />
        </mxCell>
        <mxCell id="22" value="✓" style="text;html=1;strokeColor=none;fillColor=#2E7D32;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=1;fontSize=14;fontColor=#ffffff;fontStyle=1;" vertex="1" parent="1">
          <mxGeometry x="90" y="433" width="24" height="24" as="geometry" />
        </mxCell>
        <mxCell id="23" value="userName" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=14;fontColor=#424242;fontFamily=Consolas;" vertex="1" parent="1">
          <mxGeometry x="125" y="425" width="235" height="40" as="geometry" />
        </mxCell>
        <mxCell id="24" value="" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#66BB6A;arcSize=10;" vertex="1" parent="1">
          <mxGeometry x="80" y="475" width="290" height="40" as="geometry" />
        </mxCell>
        <mxCell id="25" value="✓" style="text;html=1;strokeColor=none;fillColor=#2E7D32;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=1;fontSize=14;fontColor=#ffffff;fontStyle=1;" vertex="1" parent="1">
          <mxGeometry x="90" y="483" width="24" height="24" as="geometry" />
        </mxCell>
        <mxCell id="26" value="user_name" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=14;fontColor=#424242;fontFamily=Consolas;" vertex="1" parent="1">
          <mxGeometry x="125" y="475" width="235" height="40" as="geometry" />
        </mxCell>
        <mxCell id="27" value="" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#66BB6A;arcSize=10;" vertex="1" parent="1">
          <mxGeometry x="80" y="525" width="290" height="40" as="geometry" />
        </mxCell>
        <mxCell id="28" value="✓" style="text;html=1;strokeColor=none;fillColor=#2E7D32;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=1;fontSize=14;fontColor=#ffffff;fontStyle=1;" vertex="1" parent="1">
          <mxGeometry x="90" y="533" width="24" height="24" as="geometry" />
        </mxCell>
        <mxCell id="29" value="_count" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=14;fontColor=#424242;fontFamily=Consolas;" vertex="1" parent="1">
          <mxGeometry x="125" y="525" width="235" height="40" as="geometry" />
        </mxCell>
        <mxCell id="30" value="" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#66BB6A;arcSize=10;" vertex="1" parent="1">
          <mxGeometry x="80" y="575" width="290" height="40" as="geometry" />
        </mxCell>
        <mxCell id="31" value="✓" style="text;html=1;strokeColor=none;fillColor=#2E7D32;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=1;fontSize=14;fontColor=#ffffff;fontStyle=1;" vertex="1" parent="1">
          <mxGeometry x="90" y="583" width="24" height="24" as="geometry" />
        </mxCell>
        <mxCell id="32" value="$money" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=14;fontColor=#424242;fontFamily=Consolas;" vertex="1" parent="1">
          <mxGeometry x="125" y="575" width="235" height="40" as="geometry" />
        </mxCell>
        <mxCell id="33" value="" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#66BB6A;arcSize=10;" vertex="1" parent="1">
          <mxGeometry x="80" y="625" width="290" height="40" as="geometry" />
        </mxCell>
        <mxCell id="34" value="✓" style="text;html=1;strokeColor=none;fillColor=#2E7D32;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=1;fontSize=14;fontColor=#ffffff;fontStyle=1;" vertex="1" parent="1">
          <mxGeometry x="90" y="633" width="24" height="24" as="geometry" />
        </mxCell>
        <mxCell id="35" value="User2 / 中文变量" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=14;fontColor=#424242;fontFamily=Consolas;" vertex="1" parent="1">
          <mxGeometry x="125" y="625" width="235" height="40" as="geometry" />
        </mxCell>
        <mxCell id="36" value="" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#FFEBEE;strokeColor=#EF9A9A;strokeWidth=2;arcSize=6;" vertex="1" parent="1">
          <mxGeometry x="410" y="370" width="360" height="310" as="geometry" />
        </mxCell>
        <mxCell id="37" value="❌ 非法标识符" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=18;fontStyle=1;fontColor=#C62828;" vertex="1" parent="1">
          <mxGeometry x="410" y="380" width="360" height="35" as="geometry" />
        </mxCell>
        <mxCell id="38" value="" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#EF5350;arcSize=10;" vertex="1" parent="1">
          <mxGeometry x="430" y="425" width="320" height="40" as="geometry" />
        </mxCell>
        <mxCell id="39" value="✗" style="text;html=1;strokeColor=none;fillColor=#C62828;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=1;fontSize=14;fontColor=#ffffff;fontStyle=1;" vertex="1" parent="1">
          <mxGeometry x="440" y="433" width="24" height="24" as="geometry" />
        </mxCell>
        <mxCell id="40" value="2ndUser" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=14;fontColor=#424242;fontFamily=Consolas;" vertex="1" parent="1">
          <mxGeometry x="475" y="425" width="90" height="40" as="geometry" />
        </mxCell>
        <mxCell id="41" value="数字开头" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=12;fontColor=#9E9E9E;fontStyle=2;" vertex="1" parent="1">
          <mxGeometry x="580" y="425" width="160" height="40" as="geometry" />
        </mxCell>
        <mxCell id="42" value="" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#EF5350;arcSize=10;" vertex="1" parent="1">
          <mxGeometry x="430" y="475" width="320" height="40" as="geometry" />
        </mxCell>
        <mxCell id="43" value="✗" style="text;html=1;strokeColor=none;fillColor=#C62828;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=1;fontSize=14;fontColor=#ffffff;fontStyle=1;" vertex="1" parent="1">
          <mxGeometry x="440" y="483" width="24" height="24" as="geometry" />
        </mxCell>
        <mxCell id="44" value="user-name" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=14;fontColor=#424242;fontFamily=Consolas;" vertex="1" parent="1">
          <mxGeometry x="475" y="475" width="90" height="40" as="geometry" />
        </mxCell>
        <mxCell id="45" value="含非法字符 -" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=12;fontColor=#9E9E9E;fontStyle=2;" vertex="1" parent="1">
          <mxGeometry x="580" y="475" width="160" height="40" as="geometry" />
        </mxCell>
        <mxCell id="46" value="" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#EF5350;arcSize=10;" vertex="1" parent="1">
          <mxGeometry x="430" y="525" width="320" height="40" as="geometry" />
        </mxCell>
        <mxCell id="47" value="✗" style="text;html=1;strokeColor=none;fillColor=#C62828;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=1;fontSize=14;fontColor=#ffffff;fontStyle=1;" vertex="1" parent="1">
          <mxGeometry x="440" y="533" width="24" height="24" as="geometry" />
        </mxCell>
        <mxCell id="48" value="class" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=14;fontColor=#424242;fontFamily=Consolas;" vertex="1" parent="1">
          <mxGeometry x="475" y="525" width="90" height="40" as="geometry" />
        </mxCell>
        <mxCell id="49" value="关键字" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=12;fontColor=#9E9E9E;fontStyle=2;" vertex="1" parent="1">
          <mxGeometry x="580" y="525" width="160" height="40" as="geometry" />
        </mxCell>
        <mxCell id="50" value="" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#EF5350;arcSize=10;" vertex="1" parent="1">
          <mxGeometry x="430" y="575" width="320" height="40" as="geometry" />
        </mxCell>
        <mxCell id="51" value="✗" style="text;html=1;strokeColor=none;fillColor=#C62828;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=1;fontSize=14;fontColor=#ffffff;fontStyle=1;" vertex="1" parent="1">
          <mxGeometry x="440" y="583" width="24" height="24" as="geometry" />
        </mxCell>
        <mxCell id="52" value="my name" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=14;fontColor=#424242;fontFamily=Consolas;" vertex="1" parent="1">
          <mxGeometry x="475" y="575" width="90" height="40" as="geometry" />
        </mxCell>
        <mxCell id="53" value="含空格" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=12;fontColor=#9E9E9E;fontStyle=2;" vertex="1" parent="1">
          <mxGeometry x="580" y="575" width="160" height="40" as="geometry" />
        </mxCell>
        <mxCell id="54" value="" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#EF5350;arcSize=10;" vertex="1" parent="1">
          <mxGeometry x="430" y="625" width="320" height="40" as="geometry" />
        </mxCell>
        <mxCell id="55" value="✗" style="text;html=1;strokeColor=none;fillColor=#C62828;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=1;fontSize=14;fontColor=#ffffff;fontStyle=1;" vertex="1" parent="1">
          <mxGeometry x="440" y="633" width="24" height="24" as="geometry" />
        </mxCell>
        <mxCell id="56" value="user@email" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=14;fontColor=#424242;fontFamily=Consolas;" vertex="1" parent="1">
          <mxGeometry x="475" y="625" width="90" height="40" as="geometry" />
        </mxCell>
        <mxCell id="57" value="含非法字符 @" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=12;fontColor=#9E9E9E;fontStyle=2;" vertex="1" parent="1">
          <mxGeometry x="580" y="625" width="160" height="40" as="geometry" />
        </mxCell>
      </root>
    </mxGraphModel>
  </diagram>
</mxfile>

命名规范(约定俗成)

// ═══════════════════════════════════════════════════════════════════════
// 类名、接口名:大驼峰 (UpperCamelCase)
// ═══════════════════════════════════════════════════════════════════════
public class UserService { }
public interface OrderRepository { }
public class IOException extends Exception { }

// ═══════════════════════════════════════════════════════════════════════
// 方法名、变量名:小驼峰 (lowerCamelCase)  
// ═══════════════════════════════════════════════════════════════════════
public void getUserById() { }
int itemCount = 0;
String firstName = "John";

// ═══════════════════════════════════════════════════════════════════════
// 常量名:全大写 + 下划线分隔 (SCREAMING_SNAKE_CASE)
// ═══════════════════════════════════════════════════════════════════════
public static final int MAX_RETRY_COUNT = 3;
public static final String DEFAULT_CHARSET = "UTF-8";
public static final double PI = 3.14159265358979;

// ═══════════════════════════════════════════════════════════════════════
// 包名:全小写,用点分隔
// ═══════════════════════════════════════════════════════════════════════
package com.example.project.module;
package org.apache.commons.lang3;

// ═══════════════════════════════════════════════════════════════════════
// 泛型类型参数:单个大写字母
// ═══════════════════════════════════════════════════════════════════════
public class Box<T> { }                    // T - Type
public class Map<K, V> { }                 // K - Key, V - Value
public class List<E> { }                   // E - Element
public <R> R execute(Supplier<R> supplier) // R - Return

2.2 关键字

<mxfile>
  <diagram id="keyword-definition" name="关键字定义">
    <mxGraphModel dx="900" dy="680" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="850" pageHeight="580">
      <root>
        <mxCell id="0" />
        <mxCell id="1" parent="0" />
        <mxCell id="2" value="" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#FAFAFA;strokeColor=#424242;strokeWidth=2;arcSize=4;" vertex="1" parent="1">
          <mxGeometry x="30" y="20" width="790" height="540" as="geometry" />
        </mxCell>
        <mxCell id="3" value="关键字定义" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=26;fontStyle=1;fontColor=#1a1a1a;" vertex="1" parent="1">
          <mxGeometry x="320" y="40" width="210" height="45" as="geometry" />
        </mxCell>
        <mxCell id="4" value="" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#E3F2FD;strokeColor=#1565C0;strokeWidth=2;arcSize=8;" vertex="1" parent="1">
          <mxGeometry x="60" y="100" width="730" height="80" as="geometry" />
        </mxCell>
        <mxCell id="5" value="🔑" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=32;" vertex="1" parent="1">
          <mxGeometry x="80" y="115" width="50" height="50" as="geometry" />
        </mxCell>
        <mxCell id="6" value="关键字 (Keyword)" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=20;fontStyle=1;fontColor=#1565C0;" vertex="1" parent="1">
          <mxGeometry x="140" y="110" width="200" height="30" as="geometry" />
        </mxCell>
        <mxCell id="7" value="被 Java 语言赋予特殊含义的保留标识符" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=16;fontColor=#424242;" vertex="1" parent="1">
          <mxGeometry x="140" y="142" width="600" height="30" as="geometry" />
        </mxCell>
        <mxCell id="8" value="核心特征" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=18;fontStyle=1;fontColor=#2E7D32;" vertex="1" parent="1">
          <mxGeometry x="60" y="200" width="120" height="35" as="geometry" />
        </mxCell>
        <mxCell id="9" value="" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#E8F5E9;strokeColor=#A5D6A7;strokeWidth=2;arcSize=6;" vertex="1" parent="1">
          <mxGeometry x="60" y="245" width="730" height="130" as="geometry" />
        </mxCell>
        <mxCell id="10" value="" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#66BB6A;arcSize=10;" vertex="1" parent="1">
          <mxGeometry x="80" y="265" width="220" height="90" as="geometry" />
        </mxCell>
        <mxCell id="11" value="🚫" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=28;" vertex="1" parent="1">
          <mxGeometry x="95" y="275" width="40" height="40" as="geometry" />
        </mxCell>
        <mxCell id="12" value="不能用作命名" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=15;fontStyle=1;fontColor=#2E7D32;" vertex="1" parent="1">
          <mxGeometry x="140" y="275" width="150" height="25" as="geometry" />
        </mxCell>
        <mxCell id="13" value="类名、方法名、变量名等" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=13;fontColor=#616161;" vertex="1" parent="1">
          <mxGeometry x="140" y="300" width="150" height="45" as="geometry" />
        </mxCell>
        <mxCell id="14" value="" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#66BB6A;arcSize=10;" vertex="1" parent="1">
          <mxGeometry x="315" y="265" width="220" height="90" as="geometry" />
        </mxCell>
        <mxCell id="15" value="🔡" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=28;" vertex="1" parent="1">
          <mxGeometry x="330" y="275" width="40" height="40" as="geometry" />
        </mxCell>
        <mxCell id="16" value="全部小写" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=15;fontStyle=1;fontColor=#2E7D32;" vertex="1" parent="1">
          <mxGeometry x="375" y="275" width="150" height="25" as="geometry" />
        </mxCell>
        <mxCell id="17" value="所有关键字均为小写字母" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=13;fontColor=#616161;" vertex="1" parent="1">
          <mxGeometry x="375" y="300" width="150" height="45" as="geometry" />
        </mxCell>
        <mxCell id="18" value="" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#66BB6A;arcSize=10;" vertex="1" parent="1">
          <mxGeometry x="550" y="265" width="220" height="90" as="geometry" />
        </mxCell>
        <mxCell id="19" value="5️⃣0️⃣" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=20;" vertex="1" parent="1">
          <mxGeometry x="565" y="275" width="40" height="40" as="geometry" />
        </mxCell>
        <mxCell id="20" value="共 50 个" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=15;fontStyle=1;fontColor=#2E7D32;" vertex="1" parent="1">
          <mxGeometry x="610" y="275" width="150" height="25" as="geometry" />
        </mxCell>
        <mxCell id="21" value="包含 2 个保留字" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=13;fontColor=#616161;" vertex="1" parent="1">
          <mxGeometry x="610" y="300" width="150" height="45" as="geometry" />
        </mxCell>
        <mxCell id="22" value="💡 类比理解" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=18;fontStyle=1;fontColor=#F57C00;" vertex="1" parent="1">
          <mxGeometry x="60" y="395" width="140" height="35" as="geometry" />
        </mxCell>
        <mxCell id="23" value="" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#FFF3E0;strokeColor=#FFCC80;strokeWidth=2;arcSize=6;" vertex="1" parent="1">
          <mxGeometry x="60" y="440" width="730" height="100" as="geometry" />
        </mxCell>
        <mxCell id="24" value="🏪" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=36;" vertex="1" parent="1">
          <mxGeometry x="90" y="460" width="60" height="60" as="geometry" />
        </mxCell>
        <mxCell id="25" value="给店铺起名时" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=14;fontColor=#616161;" vertex="1" parent="1">
          <mxGeometry x="160" y="475" width="100" height="30" as="geometry" />
        </mxCell>
        <mxCell id="26" value="" style="shape=flexArrow;endArrow=classic;html=1;fillColor=#F57C00;strokeColor=none;width=20;endSize=6;endWidth=20;" edge="1" parent="1">
          <mxGeometry width="50" height="50" relative="1" as="geometry">
            <mxPoint x="270" y="489.5" as="sourcePoint" />
            <mxPoint x="330" y="489.5" as="targetPoint" />
          </mxGeometry>
        </mxCell>
        <mxCell id="27" value="" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#FFCCBC;strokeColor=#FF8A65;arcSize=10;" vertex="1" parent="1">
          <mxGeometry x="345" y="460" width="200" height="60" as="geometry" />
        </mxCell>
        <mxCell id="28" value="❌ 不能叫" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=13;fontColor=#D84315;fontStyle=1;" vertex="1" parent="1">
          <mxGeometry x="355" y="465" width="80" height="25" as="geometry" />
        </mxCell>
        <mxCell id="29" value="&quot;警察局&quot;  &quot;医院&quot;" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=14;fontColor=#424242;fontStyle=1;" vertex="1" parent="1">
          <mxGeometry x="355" y="490" width="180" height="25" as="geometry" />
        </mxCell>
        <mxCell id="30" value="=" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=24;fontColor=#757575;fontStyle=1;" vertex="1" parent="1">
          <mxGeometry x="555" y="470" width="40" height="40" as="geometry" />
        </mxCell>
        <mxCell id="31" value="" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#E3F2FD;strokeColor=#64B5F6;arcSize=10;" vertex="1" parent="1">
          <mxGeometry x="605" y="460" width="165" height="60" as="geometry" />
        </mxCell>
        <mxCell id="32" value="Java 中不能用" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=13;fontColor=#1565C0;fontStyle=1;" vertex="1" parent="1">
          <mxGeometry x="615" y="465" width="145" height="25" as="geometry" />
        </mxCell>
        <mxCell id="33" value="class  public  int" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=14;fontColor=#424242;fontFamily=Consolas;fontStyle=1;" vertex="1" parent="1">
          <mxGeometry x="615" y="490" width="145" height="25" as="geometry" />
        </mxCell>
      </root>
    </mxGraphModel>
  </diagram>
</mxfile>

Java 关键字分类一览

<mxfile>
  <diagram id="java-keywords-classification" name="Java关键字分类">
    <mxGraphModel dx="1281" dy="581" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="1000" pageHeight="1400" math="0" shadow="0">
      <root>
        <mxCell id="0" />
        <mxCell id="1" parent="0" />
        <mxCell id="2" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#FAFAFA;strokeColor=#424242;strokeWidth=2;arcSize=2;" value="" vertex="1">
          <mxGeometry height="1310" width="940" x="30" y="20" as="geometry" />
        </mxCell>
        <mxCell id="3" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=28;fontStyle=1;fontColor=#1a1a1a;" value="Java 关键字分类" vertex="1">
          <mxGeometry height="50" width="300" x="350" y="40" as="geometry" />
        </mxCell>
        <mxCell id="4" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#E3F2FD;strokeColor=#1565C0;strokeWidth=2;arcSize=4;" value="" vertex="1">
          <mxGeometry height="100" width="880" x="60" y="110" as="geometry" />
        </mxCell>
        <mxCell id="5" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=18;fontStyle=1;fontColor=#1565C0;" value="访问控制 (3个)" vertex="1">
          <mxGeometry height="30" width="200" x="80" y="120" as="geometry" />
        </mxCell>
        <mxCell id="6" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#BBDEFB;strokeColor=#64B5F6;fontSize=14;fontFamily=Consolas;fontStyle=1;" value="private" vertex="1">
          <mxGeometry height="36" width="100" x="80" y="160" as="geometry" />
        </mxCell>
        <mxCell id="7" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#BBDEFB;strokeColor=#64B5F6;fontSize=14;fontFamily=Consolas;fontStyle=1;" value="protected" vertex="1">
          <mxGeometry height="36" width="100" x="200" y="160" as="geometry" />
        </mxCell>
        <mxCell id="8" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#BBDEFB;strokeColor=#64B5F6;fontSize=14;fontFamily=Consolas;fontStyle=1;" value="public" vertex="1">
          <mxGeometry height="36" width="100" x="320" y="160" as="geometry" />
        </mxCell>
        <mxCell id="9" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#E8F5E9;strokeColor=#4CAF50;strokeWidth=2;arcSize=4;" value="" vertex="1">
          <mxGeometry height="150" width="880" x="60" y="230" as="geometry" />
        </mxCell>
        <mxCell id="10" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=18;fontStyle=1;fontColor=#2E7D32;" value="类、方法、变量修饰符 (13个)" vertex="1">
          <mxGeometry height="30" width="280" x="80" y="240" as="geometry" />
        </mxCell>
        <mxCell id="11" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#C8E6C9;strokeColor=#81C784;fontSize=14;fontFamily=Consolas;fontStyle=1;" value="abstract" vertex="1">
          <mxGeometry height="36" width="100" x="80" y="280" as="geometry" />
        </mxCell>
        <mxCell id="12" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#C8E6C9;strokeColor=#81C784;fontSize=14;fontFamily=Consolas;fontStyle=1;" value="class" vertex="1">
          <mxGeometry height="36" width="100" x="200" y="280" as="geometry" />
        </mxCell>
        <mxCell id="13" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#C8E6C9;strokeColor=#81C784;fontSize=14;fontFamily=Consolas;fontStyle=1;" value="extends" vertex="1">
          <mxGeometry height="36" width="100" x="320" y="280" as="geometry" />
        </mxCell>
        <mxCell id="14" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#C8E6C9;strokeColor=#81C784;fontSize=14;fontFamily=Consolas;fontStyle=1;" value="final" vertex="1">
          <mxGeometry height="36" width="100" x="440" y="280" as="geometry" />
        </mxCell>
        <mxCell id="15" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#C8E6C9;strokeColor=#81C784;fontSize=14;fontFamily=Consolas;fontStyle=1;" value="implements" vertex="1">
          <mxGeometry height="36" width="100" x="560" y="280" as="geometry" />
        </mxCell>
        <mxCell id="16" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#C8E6C9;strokeColor=#81C784;fontSize=14;fontFamily=Consolas;fontStyle=1;" value="interface" vertex="1">
          <mxGeometry height="36" width="100" x="80" y="330" as="geometry" />
        </mxCell>
        <mxCell id="17" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#C8E6C9;strokeColor=#81C784;fontSize=14;fontFamily=Consolas;fontStyle=1;" value="native" vertex="1">
          <mxGeometry height="36" width="100" x="200" y="330" as="geometry" />
        </mxCell>
        <mxCell id="18" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#C8E6C9;strokeColor=#81C784;fontSize=14;fontFamily=Consolas;fontStyle=1;" value="new" vertex="1">
          <mxGeometry height="36" width="100" x="320" y="330" as="geometry" />
        </mxCell>
        <mxCell id="19" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#C8E6C9;strokeColor=#81C784;fontSize=14;fontFamily=Consolas;fontStyle=1;" value="static" vertex="1">
          <mxGeometry height="36" width="100" x="440" y="330" as="geometry" />
        </mxCell>
        <mxCell id="20" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#C8E6C9;strokeColor=#81C784;fontSize=14;fontFamily=Consolas;fontStyle=1;" value="strictfp" vertex="1">
          <mxGeometry height="36" width="100" x="560" y="330" as="geometry" />
        </mxCell>
        <mxCell id="21" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#C8E6C9;strokeColor=#81C784;fontSize=14;fontFamily=Consolas;fontStyle=1;" value="synchronized" vertex="1">
          <mxGeometry height="36" width="110" x="680" y="280" as="geometry" />
        </mxCell>
        <mxCell id="22" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#C8E6C9;strokeColor=#81C784;fontSize=14;fontFamily=Consolas;fontStyle=1;" value="transient" vertex="1">
          <mxGeometry height="36" width="100" x="680" y="330" as="geometry" />
        </mxCell>
        <mxCell id="23" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#C8E6C9;strokeColor=#81C784;fontSize=14;fontFamily=Consolas;fontStyle=1;" value="volatile" vertex="1">
          <mxGeometry height="36" width="100" x="800" y="330" as="geometry" />
        </mxCell>
        <mxCell id="24" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#FFF3E0;strokeColor=#FF9800;strokeWidth=2;arcSize=4;" value="" vertex="1">
          <mxGeometry height="150" width="880" x="60" y="400" as="geometry" />
        </mxCell>
        <mxCell id="25" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=18;fontStyle=1;fontColor=#E65100;" value="流程控制 (12个)" vertex="1">
          <mxGeometry height="30" width="200" x="80" y="410" as="geometry" />
        </mxCell>
        <mxCell id="26" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#FFE0B2;strokeColor=#FFB74D;fontSize=14;fontFamily=Consolas;fontStyle=1;" value="if" vertex="1">
          <mxGeometry height="36" width="100" x="80" y="450" as="geometry" />
        </mxCell>
        <mxCell id="27" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#FFE0B2;strokeColor=#FFB74D;fontSize=14;fontFamily=Consolas;fontStyle=1;" value="else" vertex="1">
          <mxGeometry height="36" width="100" x="200" y="450" as="geometry" />
        </mxCell>
        <mxCell id="28" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#FFE0B2;strokeColor=#FFB74D;fontSize=14;fontFamily=Consolas;fontStyle=1;" value="switch" vertex="1">
          <mxGeometry height="36" width="100" x="320" y="450" as="geometry" />
        </mxCell>
        <mxCell id="29" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#FFE0B2;strokeColor=#FFB74D;fontSize=14;fontFamily=Consolas;fontStyle=1;" value="case" vertex="1">
          <mxGeometry height="36" width="100" x="440" y="450" as="geometry" />
        </mxCell>
        <mxCell id="30" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#FFE0B2;strokeColor=#FFB74D;fontSize=14;fontFamily=Consolas;fontStyle=1;" value="default" vertex="1">
          <mxGeometry height="36" width="100" x="560" y="450" as="geometry" />
        </mxCell>
        <mxCell id="31" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#FFE0B2;strokeColor=#FFB74D;fontSize=14;fontFamily=Consolas;fontStyle=1;" value="for" vertex="1">
          <mxGeometry height="36" width="100" x="680" y="450" as="geometry" />
        </mxCell>
        <mxCell id="32" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#FFE0B2;strokeColor=#FFB74D;fontSize=14;fontFamily=Consolas;fontStyle=1;" value="while" vertex="1">
          <mxGeometry height="36" width="100" x="80" y="500" as="geometry" />
        </mxCell>
        <mxCell id="33" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#FFE0B2;strokeColor=#FFB74D;fontSize=14;fontFamily=Consolas;fontStyle=1;" value="do" vertex="1">
          <mxGeometry height="36" width="100" x="200" y="500" as="geometry" />
        </mxCell>
        <mxCell id="34" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#FFE0B2;strokeColor=#FFB74D;fontSize=14;fontFamily=Consolas;fontStyle=1;" value="break" vertex="1">
          <mxGeometry height="36" width="100" x="320" y="500" as="geometry" />
        </mxCell>
        <mxCell id="35" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#FFE0B2;strokeColor=#FFB74D;fontSize=14;fontFamily=Consolas;fontStyle=1;" value="continue" vertex="1">
          <mxGeometry height="36" width="100" x="440" y="500" as="geometry" />
        </mxCell>
        <mxCell id="36" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#FFE0B2;strokeColor=#FFB74D;fontSize=14;fontFamily=Consolas;fontStyle=1;" value="return" vertex="1">
          <mxGeometry height="36" width="100" x="560" y="500" as="geometry" />
        </mxCell>
        <mxCell id="37" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#FFE0B2;strokeColor=#FFB74D;fontSize=14;fontFamily=Consolas;fontStyle=1;" value="instanceof" vertex="1">
          <mxGeometry height="36" width="100" x="680" y="500" as="geometry" />
        </mxCell>
        <mxCell id="38" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#FCE4EC;strokeColor=#E91E63;strokeWidth=2;arcSize=4;" value="" vertex="1">
          <mxGeometry height="100" width="880" x="60" y="570" as="geometry" />
        </mxCell>
        <mxCell id="39" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=18;fontStyle=1;fontColor=#C2185B;" value="异常处理 (5个)" vertex="1">
          <mxGeometry height="30" width="200" x="80" y="580" as="geometry" />
        </mxCell>
        <mxCell id="40" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#F8BBD9;strokeColor=#F06292;fontSize=14;fontFamily=Consolas;fontStyle=1;" value="try" vertex="1">
          <mxGeometry height="36" width="100" x="80" y="620" as="geometry" />
        </mxCell>
        <mxCell id="41" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#F8BBD9;strokeColor=#F06292;fontSize=14;fontFamily=Consolas;fontStyle=1;" value="catch" vertex="1">
          <mxGeometry height="36" width="100" x="200" y="620" as="geometry" />
        </mxCell>
        <mxCell id="42" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#F8BBD9;strokeColor=#F06292;fontSize=14;fontFamily=Consolas;fontStyle=1;" value="throw" vertex="1">
          <mxGeometry height="36" width="100" x="320" y="620" as="geometry" />
        </mxCell>
        <mxCell id="43" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#F8BBD9;strokeColor=#F06292;fontSize=14;fontFamily=Consolas;fontStyle=1;" value="throws" vertex="1">
          <mxGeometry height="36" width="100" x="440" y="620" as="geometry" />
        </mxCell>
        <mxCell id="44" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#F8BBD9;strokeColor=#F06292;fontSize=14;fontFamily=Consolas;fontStyle=1;" value="finally" vertex="1">
          <mxGeometry height="36" width="100" x="560" y="620" as="geometry" />
        </mxCell>
        <mxCell id="45" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#E1F5FE;strokeColor=#03A9F4;strokeWidth=2;arcSize=4;" value="" vertex="1">
          <mxGeometry height="100" width="880" x="60" y="690" as="geometry" />
        </mxCell>
        <mxCell id="46" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=18;fontStyle=1;fontColor=#0277BD;" value="包管理 (2个)" vertex="1">
          <mxGeometry height="30" width="200" x="80" y="700" as="geometry" />
        </mxCell>
        <mxCell id="47" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#B3E5FC;strokeColor=#4FC3F7;fontSize=14;fontFamily=Consolas;fontStyle=1;" value="package" vertex="1">
          <mxGeometry height="36" width="100" x="80" y="740" as="geometry" />
        </mxCell>
        <mxCell id="48" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#B3E5FC;strokeColor=#4FC3F7;fontSize=14;fontFamily=Consolas;fontStyle=1;" value="import" vertex="1">
          <mxGeometry height="36" width="100" x="200" y="740" as="geometry" />
        </mxCell>
        <mxCell id="49" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#EDE7F6;strokeColor=#673AB7;strokeWidth=2;arcSize=4;" value="" vertex="1">
          <mxGeometry height="100" width="880" x="60" y="810" as="geometry" />
        </mxCell>
        <mxCell id="50" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=18;fontStyle=1;fontColor=#512DA8;" value="基本数据类型 (8个)" vertex="1">
          <mxGeometry height="30" width="220" x="80" y="820" as="geometry" />
        </mxCell>
        <mxCell id="51" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#D1C4E9;strokeColor=#9575CD;fontSize=14;fontFamily=Consolas;fontStyle=1;" value="byte" vertex="1">
          <mxGeometry height="36" width="100" x="80" y="860" as="geometry" />
        </mxCell>
        <mxCell id="52" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#D1C4E9;strokeColor=#9575CD;fontSize=14;fontFamily=Consolas;fontStyle=1;" value="short" vertex="1">
          <mxGeometry height="36" width="100" x="200" y="860" as="geometry" />
        </mxCell>
        <mxCell id="53" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#D1C4E9;strokeColor=#9575CD;fontSize=14;fontFamily=Consolas;fontStyle=1;" value="int" vertex="1">
          <mxGeometry height="36" width="100" x="320" y="860" as="geometry" />
        </mxCell>
        <mxCell id="54" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#D1C4E9;strokeColor=#9575CD;fontSize=14;fontFamily=Consolas;fontStyle=1;" value="long" vertex="1">
          <mxGeometry height="36" width="100" x="440" y="860" as="geometry" />
        </mxCell>
        <mxCell id="55" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#D1C4E9;strokeColor=#9575CD;fontSize=14;fontFamily=Consolas;fontStyle=1;" value="float" vertex="1">
          <mxGeometry height="36" width="100" x="560" y="860" as="geometry" />
        </mxCell>
        <mxCell id="56" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#D1C4E9;strokeColor=#9575CD;fontSize=14;fontFamily=Consolas;fontStyle=1;" value="double" vertex="1">
          <mxGeometry height="36" width="100" x="680" y="860" as="geometry" />
        </mxCell>
        <mxCell id="57" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#D1C4E9;strokeColor=#9575CD;fontSize=14;fontFamily=Consolas;fontStyle=1;" value="char" vertex="1">
          <mxGeometry height="36" width="100" x="800" y="860" as="geometry" />
        </mxCell>
        <mxCell id="58" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#D1C4E9;strokeColor=#9575CD;fontSize=14;fontFamily=Consolas;fontStyle=1;" value="boolean" vertex="1">
          <mxGeometry height="36" width="100" x="80" y="860" as="geometry" />
        </mxCell>
        <mxCell id="59" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#F3E5F5;strokeColor=#9C27B0;strokeWidth=2;arcSize=4;" value="" vertex="1">
          <mxGeometry height="100" width="880" x="60" y="930" as="geometry" />
        </mxCell>
        <mxCell id="60" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=18;fontStyle=1;fontColor=#7B1FA2;" value="变量引用 (3个)" vertex="1">
          <mxGeometry height="30" width="200" x="80" y="940" as="geometry" />
        </mxCell>
        <mxCell id="61" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#E1BEE7;strokeColor=#BA68C8;fontSize=14;fontFamily=Consolas;fontStyle=1;" value="super" vertex="1">
          <mxGeometry height="36" width="100" x="80" y="980" as="geometry" />
        </mxCell>
        <mxCell id="62" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#E1BEE7;strokeColor=#BA68C8;fontSize=14;fontFamily=Consolas;fontStyle=1;" value="this" vertex="1">
          <mxGeometry height="36" width="100" x="200" y="980" as="geometry" />
        </mxCell>
        <mxCell id="63" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#E1BEE7;strokeColor=#BA68C8;fontSize=14;fontFamily=Consolas;fontStyle=1;" value="void" vertex="1">
          <mxGeometry height="36" width="100" x="320" y="980" as="geometry" />
        </mxCell>
        <mxCell id="64" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ECEFF1;strokeColor=#607D8B;strokeWidth=2;arcSize=4;" value="" vertex="1">
          <mxGeometry height="150" width="880" x="60" y="1050" as="geometry" />
        </mxCell>
        <mxCell id="65" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=18;fontStyle=1;fontColor=#455A64;" value="其他 (4个)" vertex="1">
          <mxGeometry height="30" width="200" x="80" y="1060" as="geometry" />
        </mxCell>
        <mxCell id="66" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#CFD8DC;strokeColor=#90A4AE;fontSize=14;fontFamily=Consolas;fontStyle=1;" value="assert" vertex="1">
          <mxGeometry height="36" width="100" x="80" y="1100" as="geometry" />
        </mxCell>
        <mxCell id="67" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=11;fontColor=#78909C;" value="JDK 1.4" vertex="1">
          <mxGeometry height="20" width="100" x="80" y="1136" as="geometry" />
        </mxCell>
        <mxCell id="68" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#CFD8DC;strokeColor=#90A4AE;fontSize=14;fontFamily=Consolas;fontStyle=1;" value="enum" vertex="1">
          <mxGeometry height="36" width="100" x="200" y="1100" as="geometry" />
        </mxCell>
        <mxCell id="69" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=11;fontColor=#78909C;" value="JDK 5" vertex="1">
          <mxGeometry height="20" width="100" x="200" y="1136" as="geometry" />
        </mxCell>
        <mxCell id="70" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#FFCDD2;strokeColor=#EF9A9A;fontSize=14;fontFamily=Consolas;fontStyle=1;" value="goto" vertex="1">
          <mxGeometry height="36" width="100" x="320" y="1100" as="geometry" />
        </mxCell>
        <mxCell id="71" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=11;fontColor=#E57373;" value="保留字" vertex="1">
          <mxGeometry height="20" width="100" x="320" y="1136" as="geometry" />
        </mxCell>
        <mxCell id="72" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#FFCDD2;strokeColor=#EF9A9A;fontSize=14;fontFamily=Consolas;fontStyle=1;" value="const" vertex="1">
          <mxGeometry height="36" width="100" x="440" y="1100" as="geometry" />
        </mxCell>
        <mxCell id="73" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=11;fontColor=#E57373;" value="保留字" vertex="1">
          <mxGeometry height="20" width="100" x="440" y="1136" as="geometry" />
        </mxCell>
        <mxCell id="74" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#FFF8E1;strokeColor=#FFC107;strokeWidth=2;arcSize=4;" value="" vertex="1">
          <mxGeometry height="70" width="880" x="60" y="1220" as="geometry" />
        </mxCell>
        <mxCell id="75" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=24;" value="⚠️" vertex="1">
          <mxGeometry height="40" width="40" x="80" y="1235" as="geometry" />
        </mxCell>
        <mxCell id="76" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=16;fontColor=#F57F17;fontStyle=1;" value="注意:true、false、null 看起来像关键字,但实际上是字面量" vertex="1">
          <mxGeometry height="40" width="780" x="130" y="1235" as="geometry" />
        </mxCell>
      </root>
    </mxGraphModel>
  </diagram>
</mxfile>

关键字详细说明

// ═══════════════════════════════════════════════════════════════════════
// 访问控制关键字
// ═══════════════════════════════════════════════════════════════════════

public class AccessDemo {
    public int publicVar;       // 公开:任何地方都可访问
    protected int protectedVar; // 受保护:同包 + 子类可访问
    int defaultVar;             // 默认:同包可访问 (无关键字)
    private int privateVar;     // 私有:仅本类可访问
}

// ═══════════════════════════════════════════════════════════════════════
// 类相关关键字
// ═══════════════════════════════════════════════════════════════════════

abstract class Animal { }           // abstract: 抽象类/方法
class Dog extends Animal { }        // extends: 继承
interface Runnable { }              // interface: 接口
class Cat implements Runnable { }   // implements: 实现接口
final class String { }              // final: 不可继承/修改
static int count;                   // static: 静态成员

// ═══════════════════════════════════════════════════════════════════════
// 特殊关键字
// ═══════════════════════════════════════════════════════════════════════

// native: 本地方法,由 C/C++ 实现
public native int hashCode();

// strictfp: 严格浮点计算,保证跨平台结果一致
strictfp class StrictMath { }

// transient: 序列化时忽略该字段
transient int tempData;

// volatile: 保证多线程可见性
volatile boolean flag;

// synchronized: 同步锁
synchronized void method() { }

// assert: 断言(调试用)
assert x > 0 : "x must be positive";

// enum: 枚举类型 (JDK 5+)
enum Color { RED, GREEN, BLUE }

2.3 保留字

<mxfile>
  <diagram id="java-reserved-words" name="Java保留字">
    <mxGraphModel dx="1281" dy="581" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="850" pageHeight="520" math="0" shadow="0">
      <root>
        <mxCell id="0" />
        <mxCell id="1" parent="0" />
        <mxCell id="2" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#FAFAFA;strokeColor=#607D8B;strokeWidth=3;arcSize=3;" value="" vertex="1">
          <mxGeometry height="470" width="810" x="20" y="20" as="geometry" />
        </mxCell>
        <mxCell id="3" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=28;fontStyle=1;fontColor=#37474F;" value="保留字" vertex="1">
          <mxGeometry height="50" width="200" x="320" y="40" as="geometry" />
        </mxCell>
        <mxCell id="4" parent="1" style="line;strokeWidth=2;fillColor=none;align=left;verticalAlign=middle;spacingTop=-1;spacingLeft=3;spacingRight=3;rotatable=0;labelPosition=right;points=[];portConstraint=eastwest;strokeColor=#B0BEC5;" value="" vertex="1">
          <mxGeometry height="10" width="750" x="50" y="90" as="geometry" />
        </mxCell>
        <mxCell id="5" parent="1" style="shape=callout;whiteSpace=wrap;html=1;perimeter=calloutPerimeter;fillColor=#E3F2FD;strokeColor=#1976D2;strokeWidth=2;position2=0.25;size=30;position=0.5;rounded=1;arcSize=8;" value="" vertex="1">
          <mxGeometry height="70" width="750" x="50" y="115" as="geometry" />
        </mxCell>
        <mxCell id="6" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=16;fontColor=#1565C0;fontStyle=0;" value="保留字:目前未使用但被保留的关键字,可能在未来版本中启用" vertex="1">
          <mxGeometry height="40" width="690" x="80" y="120" as="geometry" />
        </mxCell>
        <mxCell id="7" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#FFF3E0;strokeColor=#FF9800;strokeWidth=2;arcSize=6;" value="" vertex="1">
          <mxGeometry height="130" width="750" x="50" y="200" as="geometry" />
        </mxCell>
        <mxCell id="8" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#FFCC80;strokeColor=#FB8C00;fontSize=18;fontFamily=Consolas;fontStyle=1;fontColor=#E65100;" value="goto" vertex="1">
          <mxGeometry height="40" width="100" x="80" y="220" as="geometry" />
        </mxCell>
        <mxCell id="9" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=14;fontColor=#5D4037;" value="C/C++ 中的跳转语句,Java 保留但未实现(不推荐使用)" vertex="1">
          <mxGeometry height="40" width="570" x="200" y="220" as="geometry" />
        </mxCell>
        <mxCell id="10" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#FFCC80;strokeColor=#FB8C00;fontSize=18;fontFamily=Consolas;fontStyle=1;fontColor=#E65100;" value="const" vertex="1">
          <mxGeometry height="40" width="100" x="80" y="275" as="geometry" />
        </mxCell>
        <mxCell id="11" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=14;fontColor=#5D4037;" value="C/C++ 中的常量定义,Java 用 &lt;font color=&quot;#2e7d32&quot;&gt;&lt;b&gt;final&lt;/b&gt;&lt;/font&gt; 代替" vertex="1">
          <mxGeometry height="40" width="570" x="200" y="275" as="geometry" />
        </mxCell>
        <mxCell id="12" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=16;fontColor=#D84315;fontStyle=1;" value="⚠️ 虽然未启用,但也不能用作标识符:" vertex="1">
          <mxGeometry height="30" width="400" x="50" y="350" as="geometry" />
        </mxCell>
        <mxCell id="13" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#FFEBEE;strokeColor=#EF5350;strokeWidth=2;arcSize=6;" value="" vertex="1">
          <mxGeometry height="70" width="750" x="50" y="390" as="geometry" />
        </mxCell>
        <mxCell id="14" parent="1" style="text;html=1;strokeColor=none;fillColor=#FFCDD2;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=1;fontSize=16;fontFamily=Consolas;fontColor=#424242;spacingLeft=10;spacingRight=10;" value="int goto = 1;" vertex="1">
          <mxGeometry height="36" width="180" x="80" y="405" as="geometry" />
        </mxCell>
        <mxCell id="15" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=14;fontColor=#C62828;fontStyle=1;" value="❌ 编译错误" vertex="1">
          <mxGeometry height="36" width="120" x="280" y="405" as="geometry" />
        </mxCell>
        <mxCell id="16" parent="1" style="text;html=1;strokeColor=none;fillColor=#FFCDD2;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=1;fontSize=16;fontFamily=Consolas;fontColor=#424242;spacingLeft=10;spacingRight=10;" value="int const = 2;" vertex="1">
          <mxGeometry height="36" width="180" x="430" y="405" as="geometry" />
        </mxCell>
        <mxCell id="17" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=14;fontColor=#C62828;fontStyle=1;" value="❌ 编译错误" vertex="1">
          <mxGeometry height="36" width="120" x="630" y="405" as="geometry" />
        </mxCell>
        <mxCell id="18" parent="1" style="shape=cross;whiteSpace=wrap;html=1;fillColor=#F44336;strokeColor=none;size=0.4;" value="" vertex="1">
          <mxGeometry height="26" width="26" x="250" y="410" as="geometry" />
        </mxCell>
        <mxCell id="19" parent="1" style="shape=cross;whiteSpace=wrap;html=1;fillColor=#F44336;strokeColor=none;size=0.4;" value="" vertex="1">
          <mxGeometry height="26" width="26" x="600" y="410" as="geometry" />
        </mxCell>
        <mxCell id="20" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=20;" value="💡" vertex="1">
          <mxGeometry height="30" width="30" x="760" y="215" as="geometry" />
        </mxCell>
        <mxCell id="21" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=20;" value="💡" vertex="1">
          <mxGeometry height="30" width="30" x="760" y="270" as="geometry" />
        </mxCell>
      </root>
    </mxGraphModel>
  </diagram>
</mxfile>

2.4 字面量 vs 关键字

 <mxfile>
  <diagram id="java-literals" name="Java字面量">
    <mxGraphModel dx="1068" dy="484" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="900" pageHeight="680" math="0" shadow="0">
      <root>
        <mxCell id="0" />
        <mxCell id="1" parent="0" />
        <mxCell id="2" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#FAFAFA;strokeColor=#5C6BC0;strokeWidth=3;arcSize=3;" value="" vertex="1">
          <mxGeometry height="650" width="860" x="20" y="20" as="geometry" />
        </mxCell>
        <mxCell id="3" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=22;fontStyle=1;fontColor=#303F9F;" value="true、false、null 是字面量(Literal),不是关键字" vertex="1">
          <mxGeometry height="40" width="700" x="100" y="40" as="geometry" />
        </mxCell>
        <mxCell id="4" parent="1" style="line;strokeWidth=3;fillColor=none;align=left;verticalAlign=middle;spacingTop=-1;spacingLeft=3;spacingRight=3;rotatable=0;labelPosition=right;points=[];portConstraint=eastwest;strokeColor=#7986CB;" value="" vertex="1">
          <mxGeometry height="10" width="800" x="50" y="90" as="geometry" />
        </mxCell>
        <mxCell id="5" parent="1" style="text;html=1;strokeColor=none;fillColor=#3F51B5;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=1;fontSize=14;fontStyle=1;fontColor=#FFFFFF;" value="核心概念" vertex="1">
          <mxGeometry height="30" width="100" x="50" y="110" as="geometry" />
        </mxCell>
        <mxCell id="6" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#E8EAF6;strokeColor=#5C6BC0;strokeWidth=2;arcSize=8;" value="" vertex="1">
          <mxGeometry height="130" width="800" x="50" y="155" as="geometry" />
        </mxCell>
        <mxCell id="7" parent="1" style="text;html=1;strokeColor=none;fillColor=#C5CAE9;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=1;fontSize=15;fontFamily=Consolas;fontColor=#37474F;spacingLeft=10;" value="boolean flag = &lt;font color=&quot;#1565c0&quot;&gt;&lt;b&gt;true&lt;/b&gt;&lt;/font&gt;;" vertex="1">
          <mxGeometry height="32" width="240" x="70" y="165" as="geometry" />
        </mxCell>
        <mxCell id="8" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=13;fontColor=#689F38;fontStyle=2;" value="// true 是布尔字面量" vertex="1">
          <mxGeometry height="32" width="200" x="330" y="165" as="geometry" />
        </mxCell>
        <mxCell id="9" parent="1" style="text;html=1;strokeColor=none;fillColor=#C5CAE9;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=1;fontSize=15;fontFamily=Consolas;fontColor=#37474F;spacingLeft=10;" value="boolean other = &lt;font color=&quot;#1565c0&quot;&gt;&lt;b&gt;false&lt;/b&gt;&lt;/font&gt;;" vertex="1">
          <mxGeometry height="32" width="240" x="70" y="205" as="geometry" />
        </mxCell>
        <mxCell id="10" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=13;fontColor=#689F38;fontStyle=2;" value="// false 是布尔字面量" vertex="1">
          <mxGeometry height="32" width="200" x="330" y="205" as="geometry" />
        </mxCell>
        <mxCell id="11" parent="1" style="text;html=1;strokeColor=none;fillColor=#C5CAE9;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=1;fontSize=15;fontFamily=Consolas;fontColor=#37474F;spacingLeft=10;" value="String str = &lt;font color=&quot;#1565c0&quot;&gt;&lt;b&gt;null&lt;/b&gt;&lt;/font&gt;;" vertex="1">
          <mxGeometry height="32" width="240" x="70" y="245" as="geometry" />
        </mxCell>
        <mxCell id="12" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=13;fontColor=#689F38;fontStyle=2;" value="// null 是空引用字面量" vertex="1">
          <mxGeometry height="32" width="200" x="330" y="245" as="geometry" />
        </mxCell>
        <mxCell id="13" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#FFF8E1;strokeColor=#FFB300;strokeWidth=2;arcSize=10;" value="" vertex="1">
          <mxGeometry height="110" width="270" x="560" y="165" as="geometry" />
        </mxCell>
        <mxCell id="14" parent="1" style="text;html=1;strokeColor=none;fillColor=#FFD54F;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=1;fontSize=13;fontStyle=1;fontColor=#5D4037;" value="💡 JVM 角度" vertex="1">
          <mxGeometry height="26" width="90" x="575" y="175" as="geometry" />
        </mxCell>
        <mxCell id="15" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=13;fontColor=#5D4037;" value="&lt;b&gt;字面量&lt;/b&gt;:直接表示值的常量&lt;br&gt;&lt;b&gt;关键字&lt;/b&gt;:语法的一部分,&lt;br&gt;用于构建程序结构" vertex="1">
          <mxGeometry height="60" width="240" x="575" y="205" as="geometry" />
        </mxCell>
        <mxCell id="16" parent="1" style="text;html=1;strokeColor=none;fillColor=#7C4DFF;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=1;fontSize=14;fontStyle=1;fontColor=#FFFFFF;" value="字面量 vs 关键字" vertex="1">
          <mxGeometry height="30" width="130" x="50" y="300" as="geometry" />
        </mxCell>
        <mxCell id="17" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#E1F5FE;strokeColor=#03A9F4;strokeWidth=2;arcSize=8;" value="" vertex="1">
          <mxGeometry height="140" width="380" x="50" y="340" as="geometry" />
        </mxCell>
        <mxCell id="18" parent="1" style="text;html=1;strokeColor=none;fillColor=#03A9F4;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=1;fontSize=14;fontStyle=1;fontColor=#FFFFFF;" value="字面量 (Literal)" vertex="1">
          <mxGeometry height="28" width="130" x="140" y="350" as="geometry" />
        </mxCell>
        <mxCell id="19" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=13;fontColor=#01579B;" value="✓ 直接表示数据值&lt;br&gt;✓ 编译时确定&lt;br&gt;✓ 存储在常量池中" vertex="1">
          <mxGeometry height="80" width="160" x="70" y="385" as="geometry" />
        </mxCell>
        <mxCell id="20" parent="1" style="text;html=1;strokeColor=none;fillColor=#B3E5FC;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=1;fontSize=13;fontColor=#0277BD;fontStyle=1;" value="&lt;font face=&quot;Consolas&quot;&gt;true&lt;/font&gt;, &lt;font face=&quot;Consolas&quot;&gt;false&lt;/font&gt;, &lt;font face=&quot;Consolas&quot;&gt;null&lt;/font&gt;&lt;br&gt;&lt;font face=&quot;Consolas&quot;&gt;100&lt;/font&gt;, &lt;font face=&quot;Consolas&quot;&gt;3.14&lt;/font&gt;, &lt;font face=&quot;Consolas&quot;&gt;&quot;Hello&quot;&lt;/font&gt;" vertex="1">
          <mxGeometry height="70" width="170" x="240" y="390" as="geometry" />
        </mxCell>
        <mxCell id="21" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#F3E5F5;strokeColor=#9C27B0;strokeWidth=2;arcSize=8;" value="" vertex="1">
          <mxGeometry height="140" width="380" x="470" y="340" as="geometry" />
        </mxCell>
        <mxCell id="22" parent="1" style="text;html=1;strokeColor=none;fillColor=#9C27B0;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=1;fontSize=14;fontStyle=1;fontColor=#FFFFFF;" value="关键字 (Keyword)" vertex="1">
          <mxGeometry height="28" width="130" x="560" y="350" as="geometry" />
        </mxCell>
        <mxCell id="23" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=13;fontColor=#6A1B9A;" value="✓ 定义程序结构&lt;br&gt;✓ 语法保留字&lt;br&gt;✓ 不能作标识符" vertex="1">
          <mxGeometry height="80" width="160" x="490" y="385" as="geometry" />
        </mxCell>
        <mxCell id="24" parent="1" style="text;html=1;strokeColor=none;fillColor=#E1BEE7;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=1;fontSize=13;fontColor=#7B1FA2;fontStyle=1;" value="&lt;font face=&quot;Consolas&quot;&gt;class&lt;/font&gt;, &lt;font face=&quot;Consolas&quot;&gt;if&lt;/font&gt;, &lt;font face=&quot;Consolas&quot;&gt;for&lt;/font&gt;&lt;br&gt;&lt;font face=&quot;Consolas&quot;&gt;public&lt;/font&gt;, &lt;font face=&quot;Consolas&quot;&gt;void&lt;/font&gt;, &lt;font face=&quot;Consolas&quot;&gt;int&lt;/font&gt;" vertex="1">
          <mxGeometry height="70" width="170" x="660" y="390" as="geometry" />
        </mxCell>
        <mxCell id="25" parent="1" style="text;html=1;strokeColor=none;fillColor=#4CAF50;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=1;fontSize=14;fontStyle=1;fontColor=#FFFFFF;" value="其他字面量示例" vertex="1">
          <mxGeometry height="30" width="130" x="50" y="500" as="geometry" />
        </mxCell>
        <mxCell id="26" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#E8F5E9;strokeColor=#4CAF50;strokeWidth=2;arcSize=6;" value="" vertex="1">
          <mxGeometry height="110" width="800" x="50" y="540" as="geometry" />
        </mxCell>
        <mxCell id="27" parent="1" style="text;html=1;strokeColor=none;fillColor=#C8E6C9;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=1;fontSize=13;fontFamily=Consolas;fontColor=#37474F;spacingLeft=8;" value="int decimal = &lt;font color=&quot;#d84315&quot;&gt;&lt;b&gt;100&lt;/b&gt;&lt;/font&gt;;" vertex="1">
          <mxGeometry height="28" width="170" x="70" y="555" as="geometry" />
        </mxCell>
        <mxCell id="28" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=11;fontColor=#2E7D32;" value="十进制" vertex="1">
          <mxGeometry height="20" width="60" x="70" y="583" as="geometry" />
        </mxCell>
        <mxCell id="29" parent="1" style="text;html=1;strokeColor=none;fillColor=#C8E6C9;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=1;fontSize=13;fontFamily=Consolas;fontColor=#37474F;spacingLeft=8;" value="int hex = &lt;font color=&quot;#d84315&quot;&gt;&lt;b&gt;0xFF&lt;/b&gt;&lt;/font&gt;;" vertex="1">
          <mxGeometry height="28" width="150" x="260" y="555" as="geometry" />
        </mxCell>
        <mxCell id="30" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=11;fontColor=#2E7D32;" value="十六进制" vertex="1">
          <mxGeometry height="20" width="60" x="260" y="583" as="geometry" />
        </mxCell>
        <mxCell id="31" parent="1" style="text;html=1;strokeColor=none;fillColor=#C8E6C9;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=1;fontSize=13;fontFamily=Consolas;fontColor=#37474F;spacingLeft=8;" value="int bin = &lt;font color=&quot;#d84315&quot;&gt;&lt;b&gt;0b1010&lt;/b&gt;&lt;/font&gt;;" vertex="1">
          <mxGeometry height="28" width="160" x="430" y="555" as="geometry" />
        </mxCell>
        <mxCell id="32" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=11;fontColor=#2E7D32;" value="二进制 (JDK7+)" vertex="1">
          <mxGeometry height="20" width="100" x="430" y="583" as="geometry" />
        </mxCell>
        <mxCell id="33" parent="1" style="text;html=1;strokeColor=none;fillColor=#C8E6C9;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=1;fontSize=13;fontFamily=Consolas;fontColor=#37474F;spacingLeft=8;" value="double pi = &lt;font color=&quot;#d84315&quot;&gt;&lt;b&gt;3.14&lt;/b&gt;&lt;/font&gt;;" vertex="1">
          <mxGeometry height="28" width="170" x="70" y="605" as="geometry" />
        </mxCell>
        <mxCell id="34" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=11;fontColor=#2E7D32;" value="浮点数" vertex="1">
          <mxGeometry height="20" width="50" x="70" y="628" as="geometry" />
        </mxCell>
        <mxCell id="35" parent="1" style="text;html=1;strokeColor=none;fillColor=#C8E6C9;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=1;fontSize=13;fontFamily=Consolas;fontColor=#37474F;spacingLeft=8;" value="char c = &lt;font color=&quot;#d84315&quot;&gt;&lt;b&gt;&#39;A&#39;&lt;/b&gt;&lt;/font&gt;;" vertex="1">
          <mxGeometry height="28" width="150" x="260" y="605" as="geometry" />
        </mxCell>
        <mxCell id="36" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=11;fontColor=#2E7D32;" value="字符" vertex="1">
          <mxGeometry height="20" width="40" x="260" y="628" as="geometry" />
        </mxCell>
        <mxCell id="37" parent="1" style="text;html=1;strokeColor=none;fillColor=#C8E6C9;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=1;fontSize=13;fontFamily=Consolas;fontColor=#37474F;spacingLeft=8;" value="String s = &lt;font color=&quot;#d84315&quot;&gt;&lt;b&gt;&quot;Hello&quot;&lt;/b&gt;&lt;/font&gt;;" vertex="1">
          <mxGeometry height="28" width="180" x="430" y="605" as="geometry" />
        </mxCell>
        <mxCell id="38" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=11;fontColor=#2E7D32;" value="字符串" vertex="1">
          <mxGeometry height="20" width="50" x="430" y="628" as="geometry" />
        </mxCell>
        <mxCell id="39" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=36;fontStyle=1;fontColor=#FF5722;" value="≠" vertex="1">
          <mxGeometry height="60" width="40" x="430" y="380" as="geometry" />
        </mxCell>
        <mxCell id="40" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=24;" value="📌" vertex="1">
          <mxGeometry height="30" width="30" x="810" y="545" as="geometry" />
        </mxCell>
      </root>
    </mxGraphModel>
  </diagram>
</mxfile>

三、运算符

3.1 运算符分类概览

<mxfile>
  <diagram id="java-operators" name="Java运算符分类">
    <mxGraphModel dx="1281" dy="581" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="900" pageHeight="700" math="0" shadow="0">
      <root>
        <mxCell id="0" />
        <mxCell id="1" parent="0" />
        <mxCell id="2" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#FAFAFA;strokeColor=#1565C0;strokeWidth=3;arcSize=3;" value="" vertex="1">
          <mxGeometry height="660" width="860" x="20" y="20" as="geometry" />
        </mxCell>
        <mxCell id="3" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=26;fontStyle=1;fontColor=#1565C0;" value="Java 运算符分类" vertex="1">
          <mxGeometry height="50" width="340" x="280" y="40" as="geometry" />
        </mxCell>
        <mxCell id="4" parent="1" style="line;strokeWidth=3;fillColor=none;align=left;verticalAlign=middle;spacingTop=-1;spacingLeft=3;spacingRight=3;rotatable=0;labelPosition=right;points=[];portConstraint=eastwest;strokeColor=#90CAF9;" value="" vertex="1">
          <mxGeometry height="10" width="800" x="50" y="95" as="geometry" />
        </mxCell>
        <mxCell id="5" parent="1" style="text;html=1;strokeColor=none;fillColor=#1565C0;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=1;fontSize=16;fontStyle=1;fontColor=#FFFFFF;" value="类别" vertex="1">
          <mxGeometry height="40" width="150" x="50" y="120" as="geometry" />
        </mxCell>
        <mxCell id="6" parent="1" style="text;html=1;strokeColor=none;fillColor=#1565C0;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=1;fontSize=16;fontStyle=1;fontColor=#FFFFFF;" value="运算符" vertex="1">
          <mxGeometry height="40" width="640" x="210" y="120" as="geometry" />
        </mxCell>
        <mxCell id="7" parent="1" style="text;html=1;strokeColor=none;fillColor=#E3F2FD;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=1;fontSize=15;fontStyle=1;fontColor=#1565C0;" value="算术运算符" vertex="1">
          <mxGeometry height="50" width="150" x="50" y="170" as="geometry" />
        </mxCell>
        <mxCell id="8" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#FFFFFF;strokeColor=#90CAF9;strokeWidth=2;" value="" vertex="1">
          <mxGeometry height="50" width="640" x="210" y="170" as="geometry" />
        </mxCell>
        <mxCell id="9" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#BBDEFB;strokeColor=none;fontSize=18;fontFamily=Consolas;fontStyle=1;fontColor=#0D47A1;" value="+" vertex="1">
          <mxGeometry height="30" width="45" x="225" y="180" as="geometry" />
        </mxCell>
        <mxCell id="10" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#BBDEFB;strokeColor=none;fontSize=18;fontFamily=Consolas;fontStyle=1;fontColor=#0D47A1;" value="-" vertex="1">
          <mxGeometry height="30" width="45" x="280" y="180" as="geometry" />
        </mxCell>
        <mxCell id="11" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#BBDEFB;strokeColor=none;fontSize=18;fontFamily=Consolas;fontStyle=1;fontColor=#0D47A1;" value="*" vertex="1">
          <mxGeometry height="30" width="45" x="335" y="180" as="geometry" />
        </mxCell>
        <mxCell id="12" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#BBDEFB;strokeColor=none;fontSize=18;fontFamily=Consolas;fontStyle=1;fontColor=#0D47A1;" value="/" vertex="1">
          <mxGeometry height="30" width="45" x="390" y="180" as="geometry" />
        </mxCell>
        <mxCell id="13" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#BBDEFB;strokeColor=none;fontSize=18;fontFamily=Consolas;fontStyle=1;fontColor=#0D47A1;" value="%" vertex="1">
          <mxGeometry height="30" width="45" x="445" y="180" as="geometry" />
        </mxCell>
        <mxCell id="14" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#BBDEFB;strokeColor=none;fontSize=18;fontFamily=Consolas;fontStyle=1;fontColor=#0D47A1;" value="++" vertex="1">
          <mxGeometry height="30" width="45" x="500" y="180" as="geometry" />
        </mxCell>
        <mxCell id="15" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#BBDEFB;strokeColor=none;fontSize=18;fontFamily=Consolas;fontStyle=1;fontColor=#0D47A1;" value="--" vertex="1">
          <mxGeometry height="30" width="45" x="555" y="180" as="geometry" />
        </mxCell>
        <mxCell id="16" parent="1" style="text;html=1;strokeColor=none;fillColor=#E8F5E9;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=1;fontSize=15;fontStyle=1;fontColor=#2E7D32;" value="关系运算符" vertex="1">
          <mxGeometry height="50" width="150" x="50" y="230" as="geometry" />
        </mxCell>
        <mxCell id="17" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#FFFFFF;strokeColor=#A5D6A7;strokeWidth=2;" value="" vertex="1">
          <mxGeometry height="50" width="640" x="210" y="230" as="geometry" />
        </mxCell>
        <mxCell id="18" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#C8E6C9;strokeColor=none;fontSize=16;fontFamily=Consolas;fontStyle=1;fontColor=#1B5E20;" value="==" vertex="1">
          <mxGeometry height="30" width="45" x="225" y="240" as="geometry" />
        </mxCell>
        <mxCell id="19" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#C8E6C9;strokeColor=none;fontSize=16;fontFamily=Consolas;fontStyle=1;fontColor=#1B5E20;" value="!=" vertex="1">
          <mxGeometry height="30" width="45" x="280" y="240" as="geometry" />
        </mxCell>
        <mxCell id="20" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#C8E6C9;strokeColor=none;fontSize=16;fontFamily=Consolas;fontStyle=1;fontColor=#1B5E20;" value="&amp;gt;" vertex="1">
          <mxGeometry height="30" width="45" x="335" y="240" as="geometry" />
        </mxCell>
        <mxCell id="21" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#C8E6C9;strokeColor=none;fontSize=16;fontFamily=Consolas;fontStyle=1;fontColor=#1B5E20;" value="&amp;lt;" vertex="1">
          <mxGeometry height="30" width="45" x="390" y="240" as="geometry" />
        </mxCell>
        <mxCell id="22" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#C8E6C9;strokeColor=none;fontSize=16;fontFamily=Consolas;fontStyle=1;fontColor=#1B5E20;" value="&amp;gt;=" vertex="1">
          <mxGeometry height="30" width="45" x="445" y="240" as="geometry" />
        </mxCell>
        <mxCell id="23" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#C8E6C9;strokeColor=none;fontSize=16;fontFamily=Consolas;fontStyle=1;fontColor=#1B5E20;" value="&amp;lt;=" vertex="1">
          <mxGeometry height="30" width="45" x="500" y="240" as="geometry" />
        </mxCell>
        <mxCell id="24" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#C8E6C9;strokeColor=none;fontSize=14;fontFamily=Consolas;fontStyle=1;fontColor=#1B5E20;" value="instanceof" vertex="1">
          <mxGeometry height="30" width="90" x="555" y="240" as="geometry" />
        </mxCell>
        <mxCell id="25" parent="1" style="text;html=1;strokeColor=none;fillColor=#FFF3E0;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=1;fontSize=15;fontStyle=1;fontColor=#E65100;" value="逻辑运算符" vertex="1">
          <mxGeometry height="50" width="150" x="50" y="290" as="geometry" />
        </mxCell>
        <mxCell id="26" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#FFFFFF;strokeColor=#FFCC80;strokeWidth=2;" value="" vertex="1">
          <mxGeometry height="50" width="640" x="210" y="290" as="geometry" />
        </mxCell>
        <mxCell id="27" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#FFE0B2;strokeColor=none;fontSize=16;fontFamily=Consolas;fontStyle=1;fontColor=#BF360C;" value="&amp;amp;&amp;amp;" vertex="1">
          <mxGeometry height="30" width="45" x="225" y="300" as="geometry" />
        </mxCell>
        <mxCell id="28" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#FFE0B2;strokeColor=none;fontSize=16;fontFamily=Consolas;fontStyle=1;fontColor=#BF360C;" value="||" vertex="1">
          <mxGeometry height="30" width="45" x="280" y="300" as="geometry" />
        </mxCell>
        <mxCell id="29" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#FFE0B2;strokeColor=none;fontSize=16;fontFamily=Consolas;fontStyle=1;fontColor=#BF360C;" value="!" vertex="1">
          <mxGeometry height="30" width="45" x="335" y="300" as="geometry" />
        </mxCell>
        <mxCell id="30" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#FFE0B2;strokeColor=none;fontSize=16;fontFamily=Consolas;fontStyle=1;fontColor=#BF360C;" value="&amp;amp;" vertex="1">
          <mxGeometry height="30" width="45" x="390" y="300" as="geometry" />
        </mxCell>
        <mxCell id="31" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#FFE0B2;strokeColor=none;fontSize=16;fontFamily=Consolas;fontStyle=1;fontColor=#BF360C;" value="|" vertex="1">
          <mxGeometry height="30" width="45" x="445" y="300" as="geometry" />
        </mxCell>
        <mxCell id="32" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#FFE0B2;strokeColor=none;fontSize=16;fontFamily=Consolas;fontStyle=1;fontColor=#BF360C;" value="^" vertex="1">
          <mxGeometry height="30" width="45" x="500" y="300" as="geometry" />
        </mxCell>
        <mxCell id="33" parent="1" style="text;html=1;strokeColor=none;fillColor=#FCE4EC;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=1;fontSize=15;fontStyle=1;fontColor=#C2185B;" value="位运算符" vertex="1">
          <mxGeometry height="50" width="150" x="50" y="350" as="geometry" />
        </mxCell>
        <mxCell id="34" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#FFFFFF;strokeColor=#F48FB1;strokeWidth=2;" value="" vertex="1">
          <mxGeometry height="50" width="640" x="210" y="350" as="geometry" />
        </mxCell>
        <mxCell id="35" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#F8BBD9;strokeColor=none;fontSize=16;fontFamily=Consolas;fontStyle=1;fontColor=#880E4F;" value="&amp;amp;" vertex="1">
          <mxGeometry height="30" width="45" x="225" y="360" as="geometry" />
        </mxCell>
        <mxCell id="36" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#F8BBD9;strokeColor=none;fontSize=16;fontFamily=Consolas;fontStyle=1;fontColor=#880E4F;" value="|" vertex="1">
          <mxGeometry height="30" width="45" x="280" y="360" as="geometry" />
        </mxCell>
        <mxCell id="37" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#F8BBD9;strokeColor=none;fontSize=16;fontFamily=Consolas;fontStyle=1;fontColor=#880E4F;" value="^" vertex="1">
          <mxGeometry height="30" width="45" x="335" y="360" as="geometry" />
        </mxCell>
        <mxCell id="38" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#F8BBD9;strokeColor=none;fontSize=16;fontFamily=Consolas;fontStyle=1;fontColor=#880E4F;" value="~" vertex="1">
          <mxGeometry height="30" width="45" x="390" y="360" as="geometry" />
        </mxCell>
        <mxCell id="39" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#F8BBD9;strokeColor=none;fontSize=16;fontFamily=Consolas;fontStyle=1;fontColor=#880E4F;" value="&amp;lt;&amp;lt;" vertex="1">
          <mxGeometry height="30" width="45" x="445" y="360" as="geometry" />
        </mxCell>
        <mxCell id="40" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#F8BBD9;strokeColor=none;fontSize=16;fontFamily=Consolas;fontStyle=1;fontColor=#880E4F;" value="&amp;gt;&amp;gt;" vertex="1">
          <mxGeometry height="30" width="45" x="500" y="360" as="geometry" />
        </mxCell>
        <mxCell id="41" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#F8BBD9;strokeColor=none;fontSize=16;fontFamily=Consolas;fontStyle=1;fontColor=#880E4F;" value="&amp;gt;&amp;gt;&amp;gt;" vertex="1">
          <mxGeometry height="30" width="50" x="555" y="360" as="geometry" />
        </mxCell>
        <mxCell id="42" parent="1" style="text;html=1;strokeColor=none;fillColor=#EDE7F6;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=1;fontSize=15;fontStyle=1;fontColor=#512DA8;" value="赋值运算符" vertex="1">
          <mxGeometry height="50" width="150" x="50" y="410" as="geometry" />
        </mxCell>
        <mxCell id="43" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#FFFFFF;strokeColor=#B39DDB;strokeWidth=2;" value="" vertex="1">
          <mxGeometry height="50" width="640" x="210" y="410" as="geometry" />
        </mxCell>
        <mxCell id="44" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#D1C4E9;strokeColor=none;fontSize=16;fontFamily=Consolas;fontStyle=1;fontColor=#311B92;" value="=" vertex="1">
          <mxGeometry height="30" width="40" x="225" y="420" as="geometry" />
        </mxCell>
        <mxCell id="45" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#D1C4E9;strokeColor=none;fontSize=16;fontFamily=Consolas;fontStyle=1;fontColor=#311B92;" value="+=" vertex="1">
          <mxGeometry height="30" width="40" x="275" y="420" as="geometry" />
        </mxCell>
        <mxCell id="46" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#D1C4E9;strokeColor=none;fontSize=16;fontFamily=Consolas;fontStyle=1;fontColor=#311B92;" value="-=" vertex="1">
          <mxGeometry height="30" width="40" x="325" y="420" as="geometry" />
        </mxCell>
        <mxCell id="47" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#D1C4E9;strokeColor=none;fontSize=16;fontFamily=Consolas;fontStyle=1;fontColor=#311B92;" value="*=" vertex="1">
          <mxGeometry height="30" width="40" x="375" y="420" as="geometry" />
        </mxCell>
        <mxCell id="48" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#D1C4E9;strokeColor=none;fontSize=16;fontFamily=Consolas;fontStyle=1;fontColor=#311B92;" value="/=" vertex="1">
          <mxGeometry height="30" width="40" x="425" y="420" as="geometry" />
        </mxCell>
        <mxCell id="49" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#D1C4E9;strokeColor=none;fontSize=16;fontFamily=Consolas;fontStyle=1;fontColor=#311B92;" value="%=" vertex="1">
          <mxGeometry height="30" width="40" x="475" y="420" as="geometry" />
        </mxCell>
        <mxCell id="50" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#D1C4E9;strokeColor=none;fontSize=14;fontFamily=Consolas;fontStyle=1;fontColor=#311B92;" value="&amp;lt;&amp;lt;=" vertex="1">
          <mxGeometry height="30" width="45" x="525" y="420" as="geometry" />
        </mxCell>
        <mxCell id="51" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#D1C4E9;strokeColor=none;fontSize=14;fontFamily=Consolas;fontStyle=1;fontColor=#311B92;" value="&amp;gt;&amp;gt;=" vertex="1">
          <mxGeometry height="30" width="45" x="580" y="420" as="geometry" />
        </mxCell>
        <mxCell id="52" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#D1C4E9;strokeColor=none;fontSize=16;fontFamily=Consolas;fontStyle=1;fontColor=#311B92;" value="&amp;amp;=" vertex="1">
          <mxGeometry height="30" width="40" x="635" y="420" as="geometry" />
        </mxCell>
        <mxCell id="53" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#D1C4E9;strokeColor=none;fontSize=16;fontFamily=Consolas;fontStyle=1;fontColor=#311B92;" value="|=" vertex="1">
          <mxGeometry height="30" width="40" x="685" y="420" as="geometry" />
        </mxCell>
        <mxCell id="54" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#D1C4E9;strokeColor=none;fontSize=16;fontFamily=Consolas;fontStyle=1;fontColor=#311B92;" value="^=" vertex="1">
          <mxGeometry height="30" width="40" x="735" y="420" as="geometry" />
        </mxCell>
        <mxCell id="55" parent="1" style="text;html=1;strokeColor=none;fillColor=#E0F7FA;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=1;fontSize=15;fontStyle=1;fontColor=#00838F;" value="条件运算符" vertex="1">
          <mxGeometry height="50" width="150" x="50" y="470" as="geometry" />
        </mxCell>
        <mxCell id="56" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#FFFFFF;strokeColor=#80DEEA;strokeWidth=2;" value="" vertex="1">
          <mxGeometry height="50" width="640" x="210" y="470" as="geometry" />
        </mxCell>
        <mxCell id="57" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#B2EBF2;strokeColor=none;fontSize=18;fontFamily=Consolas;fontStyle=1;fontColor=#006064;" value="? :" vertex="1">
          <mxGeometry height="30" width="60" x="225" y="480" as="geometry" />
        </mxCell>
        <mxCell id="58" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=13;fontColor=#00695C;fontStyle=2;" value="三元运算符:条件 ? 值1 : 值2" vertex="1">
          <mxGeometry height="30" width="250" x="300" y="480" as="geometry" />
        </mxCell>
        <mxCell id="59" parent="1" style="text;html=1;strokeColor=none;fillColor=#ECEFF1;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=1;fontSize=15;fontStyle=1;fontColor=#455A64;" value="其他运算符" vertex="1">
          <mxGeometry height="50" width="150" x="50" y="530" as="geometry" />
        </mxCell>
        <mxCell id="60" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#FFFFFF;strokeColor=#B0BEC5;strokeWidth=2;" value="" vertex="1">
          <mxGeometry height="50" width="640" x="210" y="530" as="geometry" />
        </mxCell>
        <mxCell id="61" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#CFD8DC;strokeColor=none;fontSize=14;fontFamily=Consolas;fontStyle=1;fontColor=#263238;" value="new" vertex="1">
          <mxGeometry height="30" width="50" x="225" y="540" as="geometry" />
        </mxCell>
        <mxCell id="62" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#CFD8DC;strokeColor=none;fontSize=18;fontFamily=Consolas;fontStyle=1;fontColor=#263238;" value="." vertex="1">
          <mxGeometry height="30" width="40" x="285" y="540" as="geometry" />
        </mxCell>
        <mxCell id="63" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#CFD8DC;strokeColor=none;fontSize=18;fontFamily=Consolas;fontStyle=1;fontColor=#263238;" value="()" vertex="1">
          <mxGeometry height="30" width="40" x="335" y="540" as="geometry" />
        </mxCell>
        <mxCell id="64" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#CFD8DC;strokeColor=none;fontSize=18;fontFamily=Consolas;fontStyle=1;fontColor=#263238;" value="[]" vertex="1">
          <mxGeometry height="30" width="40" x="385" y="540" as="geometry" />
        </mxCell>
        <mxCell id="65" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#CFD8DC;strokeColor=none;fontSize=16;fontFamily=Consolas;fontStyle=1;fontColor=#263238;" value="-&amp;gt;" vertex="1">
          <mxGeometry height="30" width="45" x="435" y="540" as="geometry" />
        </mxCell>
        <mxCell id="66" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#CFD8DC;strokeColor=none;fontSize=18;fontFamily=Consolas;fontStyle=1;fontColor=#263238;" value="::" vertex="1">
          <mxGeometry height="30" width="40" x="490" y="540" as="geometry" />
        </mxCell>
        <mxCell id="67" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=11;fontColor=#546E7A;fontStyle=2;" value="Lambda" vertex="1">
          <mxGeometry height="20" width="55" x="430" y="570" as="geometry" />
        </mxCell>
        <mxCell id="68" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=11;fontColor=#546E7A;fontStyle=2;" value="方法引用" vertex="1">
          <mxGeometry height="20" width="60" x="485" y="570" as="geometry" />
        </mxCell>
        <mxCell id="69" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#FFF8E1;strokeColor=#FFB300;strokeWidth=2;arcSize=10;" value="" vertex="1">
          <mxGeometry height="60" width="800" x="50" y="600" as="geometry" />
        </mxCell>
        <mxCell id="70" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=20;" value="💡" vertex="1">
          <mxGeometry height="30" width="30" x="60" y="615" as="geometry" />
        </mxCell>
        <mxCell id="71" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=14;fontColor=#5D4037;" value="注意:&lt;font face=&quot;Consolas&quot;&gt;&amp;amp;&lt;/font&gt; &lt;font face=&quot;Consolas&quot;&gt;|&lt;/font&gt; &lt;font face=&quot;Consolas&quot;&gt;^&lt;/font&gt; 既可作为逻辑运算符(操作布尔值),也可作为位运算符(操作整数)" vertex="1">
          <mxGeometry height="40" width="740" x="95" y="610" as="geometry" />
        </mxCell>
      </root>
    </mxGraphModel>
  </diagram>
</mxfile>

3.2 自增自减运算符

<mxfile>
  <diagram id="increment-decrement" name="自增自减运算符">
    <mxGraphModel dx="1281" dy="581" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="800" pageHeight="560" math="0" shadow="0">
      <root>
        <mxCell id="0" />
        <mxCell id="1" parent="0" />
        <mxCell id="2" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#FAFAFA;strokeColor=#7B1FA2;strokeWidth=3;arcSize=3;" value="" vertex="1">
          <mxGeometry height="530" width="760" x="20" y="20" as="geometry" />
        </mxCell>
        <mxCell id="3" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=26;fontStyle=1;fontColor=#7B1FA2;" value="自增自减运算符" vertex="1">
          <mxGeometry height="45" width="300" x="250" y="40" as="geometry" />
        </mxCell>
        <mxCell id="4" parent="1" style="line;strokeWidth=3;fillColor=none;align=left;verticalAlign=middle;spacingTop=-1;spacingLeft=3;spacingRight=3;rotatable=0;labelPosition=right;points=[];portConstraint=eastwest;strokeColor=#CE93D8;" value="" vertex="1">
          <mxGeometry height="10" width="700" x="50" y="90" as="geometry" />
        </mxCell>
        <mxCell id="5" parent="1" style="text;html=1;strokeColor=none;fillColor=#4CAF50;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=1;fontSize=15;fontStyle=1;fontColor=#FFFFFF;" value="自增运算符 ++" vertex="1">
          <mxGeometry height="32" width="130" x="50" y="115" as="geometry" />
        </mxCell>
        <mxCell id="6" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#E8F5E9;strokeColor=#4CAF50;strokeWidth=2;arcSize=8;" value="" vertex="1">
          <mxGeometry height="120" width="330" x="50" y="160" as="geometry" />
        </mxCell>
        <mxCell id="7" parent="1" style="text;html=1;strokeColor=none;fillColor=#A5D6A7;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=1;fontSize=24;fontFamily=Consolas;fontStyle=1;fontColor=#1B5E20;" value="++x" vertex="1">
          <mxGeometry height="45" width="80" x="65" y="170" as="geometry" />
        </mxCell>
        <mxCell id="8" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=16;fontStyle=1;fontColor=#2E7D32;" value="前置自增" vertex="1">
          <mxGeometry height="25" width="90" x="160" y="170" as="geometry" />
        </mxCell>
        <mxCell id="9" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=14;fontColor=#388E3C;" value="先自增,后使用" vertex="1">
          <mxGeometry height="25" width="130" x="160" y="195" as="geometry" />
        </mxCell>
        <mxCell id="10" parent="1" style="text;html=1;strokeColor=none;fillColor=#A5D6A7;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=1;fontSize=24;fontFamily=Consolas;fontStyle=1;fontColor=#1B5E20;" value="x++  " vertex="1">
          <mxGeometry height="45" width="80" x="65" y="225" as="geometry" />
        </mxCell>
        <mxCell id="11" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=16;fontStyle=1;fontColor=#2E7D32;" value="后置自增" vertex="1">
          <mxGeometry height="25" width="90" x="160" y="225" as="geometry" />
        </mxCell>
        <mxCell id="12" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=14;fontColor=#388E3C;" value="先使用,后自增" vertex="1">
          <mxGeometry height="25" width="130" x="160" y="250" as="geometry" />
        </mxCell>
        <mxCell id="13" parent="1" style="text;html=1;strokeColor=none;fillColor=#F44336;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=1;fontSize=15;fontStyle=1;fontColor=#FFFFFF;" value="自减运算符 --" vertex="1">
          <mxGeometry height="32" width="130" x="420" y="115" as="geometry" />
        </mxCell>
        <mxCell id="14" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#FFEBEE;strokeColor=#F44336;strokeWidth=2;arcSize=8;" value="" vertex="1">
          <mxGeometry height="120" width="330" x="420" y="160" as="geometry" />
        </mxCell>
        <mxCell id="15" parent="1" style="text;html=1;strokeColor=none;fillColor=#EF9A9A;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=1;fontSize=24;fontFamily=Consolas;fontStyle=1;fontColor=#B71C1C;" value="--x" vertex="1">
          <mxGeometry height="45" width="80" x="435" y="170" as="geometry" />
        </mxCell>
        <mxCell id="16" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=16;fontStyle=1;fontColor=#C62828;" value="前置自减" vertex="1">
          <mxGeometry height="25" width="90" x="530" y="170" as="geometry" />
        </mxCell>
        <mxCell id="17" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=14;fontColor=#D32F2F;" value="先自减,后使用" vertex="1">
          <mxGeometry height="25" width="130" x="530" y="195" as="geometry" />
        </mxCell>
        <mxCell id="18" parent="1" style="text;html=1;strokeColor=none;fillColor=#EF9A9A;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=1;fontSize=24;fontFamily=Consolas;fontStyle=1;fontColor=#B71C1C;" value="x--" vertex="1">
          <mxGeometry height="45" width="80" x="435" y="225" as="geometry" />
        </mxCell>
        <mxCell id="19" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=16;fontStyle=1;fontColor=#C62828;" value="后置自减" vertex="1">
          <mxGeometry height="25" width="90" x="530" y="225" as="geometry" />
        </mxCell>
        <mxCell id="20" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=14;fontColor=#D32F2F;" value="先使用,后自减" vertex="1">
          <mxGeometry height="25" width="130" x="530" y="250" as="geometry" />
        </mxCell>
        <mxCell id="21" parent="1" style="text;html=1;strokeColor=none;fillColor=#FF9800;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=1;fontSize=15;fontStyle=1;fontColor=#FFFFFF;" value="📝 记忆口诀" vertex="1">
          <mxGeometry height="32" width="120" x="50" y="297" as="geometry" />
        </mxCell>
        <mxCell id="22" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#FFF3E0;strokeColor=#FF9800;strokeWidth=2;arcSize=10;" value="" vertex="1">
          <mxGeometry height="70" width="700" x="50" y="339" as="geometry" />
        </mxCell>
        <mxCell id="23" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=22;fontStyle=1;fontColor=#E65100;" value="符号在前先运算,符号在后后运算" vertex="1">
          <mxGeometry height="40" width="600" x="100" y="354" as="geometry" />
        </mxCell>
        <mxCell id="24" parent="1" style="text;html=1;strokeColor=none;fillColor=#2196F3;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=1;fontSize=15;fontStyle=1;fontColor=#FFFFFF;" value="💻 代码示例" vertex="1">
          <mxGeometry height="32" width="120" x="50" y="429" as="geometry" />
        </mxCell>
        <mxCell id="25" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#E3F2FD;strokeColor=#2196F3;strokeWidth=2;arcSize=8;" value="" vertex="1">
          <mxGeometry height="55" width="330" x="50" y="471" as="geometry" />
        </mxCell>
        <mxCell id="26" parent="1" style="text;html=1;strokeColor=none;fillColor=#BBDEFB;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=1;fontSize=14;fontFamily=Consolas;fontColor=#0D47A1;spacingLeft=8;" value="int a = 5;&lt;br&gt;int b = ++a;" vertex="1">
          <mxGeometry height="40" width="130" x="65" y="479" as="geometry" />
        </mxCell>
        <mxCell id="27" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=13;fontColor=#1565C0;fontStyle=2;" value="// a=6, b=6" vertex="1">
          <mxGeometry height="25" width="100" x="205" y="486" as="geometry" />
        </mxCell>
        <mxCell id="28" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#E3F2FD;strokeColor=#2196F3;strokeWidth=2;arcSize=8;" value="" vertex="1">
          <mxGeometry height="55" width="330" x="420" y="471" as="geometry" />
        </mxCell>
        <mxCell id="29" parent="1" style="text;html=1;strokeColor=none;fillColor=#BBDEFB;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=1;fontSize=14;fontFamily=Consolas;fontColor=#0D47A1;spacingLeft=8;" value="int a = 5;&lt;br&gt;int b = a++;" vertex="1">
          <mxGeometry height="40" width="130" x="435" y="479" as="geometry" />
        </mxCell>
        <mxCell id="30" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=13;fontColor=#1565C0;fontStyle=2;" value="// a=6, b=5" vertex="1">
          <mxGeometry height="25" width="100" x="575" y="486" as="geometry" />
        </mxCell>
        <mxCell id="31" parent="1" style="ellipse;whiteSpace=wrap;html=1;fillColor=#4CAF50;strokeColor=none;fontSize=14;fontStyle=1;fontColor=#FFFFFF;" value="①" vertex="1">
          <mxGeometry height="28" width="28" x="290" y="175" as="geometry" />
        </mxCell>
        <mxCell id="32" parent="1" style="ellipse;whiteSpace=wrap;html=1;fillColor=#81C784;strokeColor=none;fontSize=14;fontStyle=1;fontColor=#FFFFFF;" value="②" vertex="1">
          <mxGeometry height="28" width="28" x="325" y="175" as="geometry" />
        </mxCell>
        <mxCell id="33" parent="1" style="ellipse;whiteSpace=wrap;html=1;fillColor=#4CAF50;strokeColor=none;fontSize=14;fontStyle=1;fontColor=#FFFFFF;" value="②" vertex="1">
          <mxGeometry height="28" width="28" x="290" y="230" as="geometry" />
        </mxCell>
        <mxCell id="34" parent="1" style="ellipse;whiteSpace=wrap;html=1;fillColor=#81C784;strokeColor=none;fontSize=14;fontStyle=1;fontColor=#FFFFFF;" value="①" vertex="1">
          <mxGeometry height="28" width="28" x="325" y="230" as="geometry" />
        </mxCell>
        <mxCell id="35" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=11;fontColor=#2E7D32;" value="增" vertex="1">
          <mxGeometry height="18" width="28" x="290" y="200" as="geometry" />
        </mxCell>
        <mxCell id="36" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=11;fontColor=#2E7D32;" value="用" vertex="1">
          <mxGeometry height="18" width="28" x="325" y="200" as="geometry" />
        </mxCell>
        <mxCell id="37" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=11;fontColor=#2E7D32;" value="增" vertex="1">
          <mxGeometry height="18" width="28" x="290" y="255" as="geometry" />
        </mxCell>
        <mxCell id="38" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=11;fontColor=#2E7D32;" value="用" vertex="1">
          <mxGeometry height="18" width="28" x="325" y="255" as="geometry" />
        </mxCell>
        <mxCell id="39" parent="1" style="ellipse;whiteSpace=wrap;html=1;fillColor=#F44336;strokeColor=none;fontSize=14;fontStyle=1;fontColor=#FFFFFF;" value="①" vertex="1">
          <mxGeometry height="28" width="28" x="660" y="175" as="geometry" />
        </mxCell>
        <mxCell id="40" parent="1" style="ellipse;whiteSpace=wrap;html=1;fillColor=#E57373;strokeColor=none;fontSize=14;fontStyle=1;fontColor=#FFFFFF;" value="②" vertex="1">
          <mxGeometry height="28" width="28" x="695" y="175" as="geometry" />
        </mxCell>
        <mxCell id="41" parent="1" style="ellipse;whiteSpace=wrap;html=1;fillColor=#F44336;strokeColor=none;fontSize=14;fontStyle=1;fontColor=#FFFFFF;" value="②" vertex="1">
          <mxGeometry height="28" width="28" x="660" y="230" as="geometry" />
        </mxCell>
        <mxCell id="42" parent="1" style="ellipse;whiteSpace=wrap;html=1;fillColor=#E57373;strokeColor=none;fontSize=14;fontStyle=1;fontColor=#FFFFFF;" value="①" vertex="1">
          <mxGeometry height="28" width="28" x="695" y="230" as="geometry" />
        </mxCell>
        <mxCell id="43" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=11;fontColor=#C62828;" value="减" vertex="1">
          <mxGeometry height="18" width="28" x="660" y="200" as="geometry" />
        </mxCell>
        <mxCell id="44" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=11;fontColor=#C62828;" value="用" vertex="1">
          <mxGeometry height="18" width="28" x="695" y="200" as="geometry" />
        </mxCell>
        <mxCell id="45" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=11;fontColor=#C62828;" value="减" vertex="1">
          <mxGeometry height="18" width="28" x="660" y="255" as="geometry" />
        </mxCell>
        <mxCell id="46" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=11;fontColor=#C62828;" value="用" vertex="1">
          <mxGeometry height="18" width="28" x="695" y="255" as="geometry" />
        </mxCell>
      </root>
    </mxGraphModel>
  </diagram>
</mxfile>
// ═══════════════════════════════════════════════════════════════════════
// 基本用法
// ═══════════════════════════════════════════════════════════════════════

int x = 5;

int a = x++;  // a = 5, x = 6 (先赋值给a,再自增)
int b = ++x;  // b = 7, x = 7 (先自增,再赋值给b)

System.out.println("a = " + a);  // 5
System.out.println("b = " + b);  // 7
System.out.println("x = " + x);  // 7

// ═══════════════════════════════════════════════════════════════════════
// 图解执行过程
// ═══════════════════════════════════════════════════════════════════════

/*
 *  int x = 5;
 *  int a = x++;
 *
 *  执行过程:
 *  ┌─────┐         ┌─────┐         ┌─────┐
 *  │ x=5 │  ──▶    │ a=5 │  ──▶    │ x=6 │
 *  └─────┘  先取值  └─────┘  后自增  └─────┘
 *
 *
 *  int b = ++x;
 *
 *  执行过程:
 *  ┌─────┐         ┌─────┐         ┌─────┐
 *  │ x=6 │  ──▶    │ x=7 │  ──▶    │ b=7 │
 *  └─────┘  先自增  └─────┘  后取值  └─────┘
 */

经典面试题

// ═══════════════════════════════════════════════════════════════════════
// 面试题:计算 y 的值
// ═══════════════════════════════════════════════════════════════════════

int x = 5;
int y = x++ + ++x + x--;

// 详细执行过程分析:
<mxfile host="embed.diagrams.net" agent="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/143.0.0.0 Safari/537.36" version="29.2.9">
  <diagram id="expression-execution" name="表达式执行过程">
    <mxGraphModel dx="1281" dy="581" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="900" pageHeight="750" math="0" shadow="0">
      <root>
        <mxCell id="0" />
        <mxCell id="1" parent="0" />
        <mxCell id="2" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#FAFAFA;strokeColor=#5E35B1;strokeWidth=3;arcSize=3;" value="" vertex="1">
          <mxGeometry height="710" width="860" x="20" y="20" as="geometry" />
        </mxCell>
        <mxCell id="3" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=24;fontStyle=1;fontColor=#5E35B1;" value="表达式 x++ + ++x + x-- 执行过程" vertex="1">
          <mxGeometry height="40" width="540" x="180" y="35" as="geometry" />
        </mxCell>
        <mxCell id="4" parent="1" style="line;strokeWidth=3;fillColor=none;align=left;verticalAlign=middle;spacingTop=-1;spacingLeft=3;spacingRight=3;rotatable=0;labelPosition=right;points=[];portConstraint=eastwest;strokeColor=#B39DDB;" value="" vertex="1">
          <mxGeometry height="10" width="800" x="50" y="80" as="geometry" />
        </mxCell>
        <mxCell id="5" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#EDE7F6;strokeColor=#7E57C2;strokeWidth=2;arcSize=15;" value="" vertex="1">
          <mxGeometry height="50" width="800" x="50" y="100" as="geometry" />
        </mxCell>
        <mxCell id="6" parent="1" style="text;html=1;strokeColor=none;fillColor=#7E57C2;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=1;fontSize=15;fontStyle=1;fontColor=#FFFFFF;" value="初始状态" vertex="1">
          <mxGeometry height="30" width="100" x="70" y="110" as="geometry" />
        </mxCell>
        <mxCell id="7" parent="1" style="text;html=1;strokeColor=none;fillColor=#D1C4E9;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=1;fontSize=22;fontFamily=Consolas;fontStyle=1;fontColor=#4527A0;" value="x = 5" vertex="1">
          <mxGeometry height="36" width="100" x="200" y="107" as="geometry" />
        </mxCell>
        <mxCell id="8" parent="1" style="text;html=1;strokeColor=none;fillColor=#4CAF50;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=1;fontSize=14;fontStyle=1;fontColor=#FFFFFF;" value="步骤 1" vertex="1">
          <mxGeometry height="28" width="70" x="50" y="165" as="geometry" />
        </mxCell>
        <mxCell id="9" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=16;fontStyle=1;fontColor=#2E7D32;fontFamily=Consolas;" value="计算 x++" vertex="1">
          <mxGeometry height="28" width="120" x="130" y="165" as="geometry" />
        </mxCell>
        <mxCell id="10" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#E8F5E9;strokeColor=#4CAF50;strokeWidth=2;arcSize=8;" value="" vertex="1">
          <mxGeometry height="95" width="800" x="50" y="200" as="geometry" />
        </mxCell>
        <mxCell id="11" parent="1" style="text;html=1;strokeColor=none;fillColor=#A5D6A7;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=1;fontSize=13;fontStyle=1;fontColor=#1B5E20;" value="后置自增:先使用,后自增" vertex="1">
          <mxGeometry height="25" width="180" x="70" y="210" as="geometry" />
        </mxCell>
        <mxCell id="12" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=14;fontColor=#388E3C;" value="① 使用 x 的当前值" vertex="1">
          <mxGeometry height="22" width="140" x="70" y="240" as="geometry" />
        </mxCell>
        <mxCell id="13" parent="1" style="text;html=1;strokeColor=none;fillColor=#C8E6C9;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=1;fontSize=18;fontFamily=Consolas;fontStyle=1;fontColor=#1B5E20;" value="5" vertex="1">
          <mxGeometry height="28" width="40" x="215" y="237" as="geometry" />
        </mxCell>
        <mxCell id="14" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=14;fontColor=#388E3C;" value="② 然后 x 自增" vertex="1">
          <mxGeometry height="22" width="110" x="280" y="240" as="geometry" />
        </mxCell>
        <mxCell id="15" parent="1" style="text;html=1;strokeColor=none;fillColor=#C8E6C9;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=1;fontSize=16;fontFamily=Consolas;fontStyle=1;fontColor=#1B5E20;" value="x = 6" vertex="1">
          <mxGeometry height="28" width="70" x="395" y="237" as="geometry" />
        </mxCell>
        <mxCell id="16" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=14;fontStyle=1;fontColor=#2E7D32;" value="此步结果" vertex="1">
          <mxGeometry height="22" width="80" x="70" y="268" as="geometry" />
        </mxCell>
        <mxCell id="17" parent="1" style="ellipse;whiteSpace=wrap;html=1;fillColor=#4CAF50;strokeColor=none;fontSize=22;fontStyle=1;fontColor=#FFFFFF;fontFamily=Consolas;" value="5" vertex="1">
          <mxGeometry height="32" width="35" x="140" y="261" as="geometry" />
        </mxCell>
        <mxCell id="18" parent="1" style="text;html=1;strokeColor=none;fillColor=#2196F3;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=1;fontSize=14;fontStyle=1;fontColor=#FFFFFF;" value="步骤 2" vertex="1">
          <mxGeometry height="28" width="70" x="50" y="310" as="geometry" />
        </mxCell>
        <mxCell id="19" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=16;fontStyle=1;fontColor=#1565C0;fontFamily=Consolas;" value="计算 ++x" vertex="1">
          <mxGeometry height="28" width="120" x="130" y="310" as="geometry" />
        </mxCell>
        <mxCell id="20" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#E3F2FD;strokeColor=#2196F3;strokeWidth=2;arcSize=8;" value="" vertex="1">
          <mxGeometry height="95" width="800" x="50" y="345" as="geometry" />
        </mxCell>
        <mxCell id="21" parent="1" style="text;html=1;strokeColor=none;fillColor=#90CAF9;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=1;fontSize=13;fontStyle=1;fontColor=#0D47A1;" value="前置自增:先自增,后使用" vertex="1">
          <mxGeometry height="25" width="180" x="70" y="355" as="geometry" />
        </mxCell>
        <mxCell id="22" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=14;fontColor=#1976D2;" value="① 先 x 自增" vertex="1">
          <mxGeometry height="22" width="100" x="70" y="385" as="geometry" />
        </mxCell>
        <mxCell id="23" parent="1" style="text;html=1;strokeColor=none;fillColor=#BBDEFB;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=1;fontSize=16;fontFamily=Consolas;fontStyle=1;fontColor=#0D47A1;" value="x = 7" vertex="1">
          <mxGeometry height="28" width="70" x="175" y="382" as="geometry" />
        </mxCell>
        <mxCell id="24" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=14;fontColor=#1976D2;" value="② 使用自增后的值" vertex="1">
          <mxGeometry height="22" width="140" x="270" y="385" as="geometry" />
        </mxCell>
        <mxCell id="25" parent="1" style="text;html=1;strokeColor=none;fillColor=#BBDEFB;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=1;fontSize=18;fontFamily=Consolas;fontStyle=1;fontColor=#0D47A1;" value="7" vertex="1">
          <mxGeometry height="28" width="40" x="415" y="382" as="geometry" />
        </mxCell>
        <mxCell id="26" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=14;fontStyle=1;fontColor=#1565C0;" value="此步结果" vertex="1">
          <mxGeometry height="22" width="80" x="70" y="413" as="geometry" />
        </mxCell>
        <mxCell id="27" parent="1" style="ellipse;whiteSpace=wrap;html=1;fillColor=#2196F3;strokeColor=none;fontSize=22;fontStyle=1;fontColor=#FFFFFF;fontFamily=Consolas;" value="7" vertex="1">
          <mxGeometry height="37" width="35" x="140" y="403" as="geometry" />
        </mxCell>
        <mxCell id="28" parent="1" style="text;html=1;strokeColor=none;fillColor=#FF9800;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=1;fontSize=14;fontStyle=1;fontColor=#FFFFFF;" value="步骤 3" vertex="1">
          <mxGeometry height="28" width="70" x="50" y="455" as="geometry" />
        </mxCell>
        <mxCell id="29" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=16;fontStyle=1;fontColor=#E65100;fontFamily=Consolas;" value="计算 x--" vertex="1">
          <mxGeometry height="28" width="120" x="130" y="455" as="geometry" />
        </mxCell>
        <mxCell id="30" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#FFF3E0;strokeColor=#FF9800;strokeWidth=2;arcSize=8;" value="" vertex="1">
          <mxGeometry height="95" width="800" x="50" y="490" as="geometry" />
        </mxCell>
        <mxCell id="31" parent="1" style="text;html=1;strokeColor=none;fillColor=#FFCC80;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=1;fontSize=13;fontStyle=1;fontColor=#E65100;" value="后置自减:先使用,后自减" vertex="1">
          <mxGeometry height="25" width="180" x="70" y="500" as="geometry" />
        </mxCell>
        <mxCell id="32" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=14;fontColor=#F57C00;" value="① 使用 x 的当前值" vertex="1">
          <mxGeometry height="22" width="140" x="70" y="530" as="geometry" />
        </mxCell>
        <mxCell id="33" parent="1" style="text;html=1;strokeColor=none;fillColor=#FFE0B2;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=1;fontSize=18;fontFamily=Consolas;fontStyle=1;fontColor=#E65100;" value="7" vertex="1">
          <mxGeometry height="28" width="40" x="215" y="527" as="geometry" />
        </mxCell>
        <mxCell id="34" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=14;fontColor=#F57C00;" value="② 然后 x 自减" vertex="1">
          <mxGeometry height="22" width="110" x="280" y="530" as="geometry" />
        </mxCell>
        <mxCell id="35" parent="1" style="text;html=1;strokeColor=none;fillColor=#FFE0B2;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=1;fontSize=16;fontFamily=Consolas;fontStyle=1;fontColor=#E65100;" value="x = 6" vertex="1">
          <mxGeometry height="28" width="70" x="395" y="527" as="geometry" />
        </mxCell>
        <mxCell id="36" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=14;fontStyle=1;fontColor=#E65100;" value="此步结果" vertex="1">
          <mxGeometry height="22" width="80" x="70" y="558" as="geometry" />
        </mxCell>
        <mxCell id="37" parent="1" style="ellipse;whiteSpace=wrap;html=1;fillColor=#FF9800;strokeColor=none;fontSize=22;fontStyle=1;fontColor=#FFFFFF;fontFamily=Consolas;" value="7" vertex="1">
          <mxGeometry height="32" width="35" x="140" y="552" as="geometry" />
        </mxCell>
        <mxCell id="38" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#F3E5F5;strokeColor=#9C27B0;strokeWidth=3;arcSize=8;" value="" vertex="1">
          <mxGeometry height="115" width="800" x="50" y="600" as="geometry" />
        </mxCell>
        <mxCell id="39" parent="1" style="text;html=1;strokeColor=none;fillColor=#9C27B0;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=1;fontSize=15;fontStyle=1;fontColor=#FFFFFF;" value="🎯 最终计算" vertex="1">
          <mxGeometry height="30" width="110" x="70" y="615" as="geometry" />
        </mxCell>
        <mxCell id="40" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=20;fontFamily=Consolas;fontStyle=1;fontColor=#6A1B9A;" value="y =" vertex="1">
          <mxGeometry height="36" width="50" x="200" y="612" as="geometry" />
        </mxCell>
        <mxCell id="41" parent="1" style="ellipse;whiteSpace=wrap;html=1;fillColor=#4CAF50;strokeColor=none;fontSize=18;fontStyle=1;fontColor=#FFFFFF;fontFamily=Consolas;" value="5" vertex="1">
          <mxGeometry height="35" width="35" x="255" y="615" as="geometry" />
        </mxCell>
        <mxCell id="42" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=20;fontFamily=Consolas;fontStyle=1;fontColor=#6A1B9A;" value="+" vertex="1">
          <mxGeometry height="35" width="30" x="295" y="615" as="geometry" />
        </mxCell>
        <mxCell id="43" parent="1" style="ellipse;whiteSpace=wrap;html=1;fillColor=#2196F3;strokeColor=none;fontSize=18;fontStyle=1;fontColor=#FFFFFF;fontFamily=Consolas;" value="7" vertex="1">
          <mxGeometry height="35" width="35" x="330" y="615" as="geometry" />
        </mxCell>
        <mxCell id="44" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=20;fontFamily=Consolas;fontStyle=1;fontColor=#6A1B9A;" value="+" vertex="1">
          <mxGeometry height="35" width="30" x="370" y="615" as="geometry" />
        </mxCell>
        <mxCell id="45" parent="1" style="ellipse;whiteSpace=wrap;html=1;fillColor=#FF9800;strokeColor=none;fontSize=18;fontStyle=1;fontColor=#FFFFFF;fontFamily=Consolas;" value="7" vertex="1">
          <mxGeometry height="35" width="35" x="405" y="615" as="geometry" />
        </mxCell>
        <mxCell id="46" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=20;fontFamily=Consolas;fontStyle=1;fontColor=#6A1B9A;" value="=" vertex="1">
          <mxGeometry height="35" width="30" x="445" y="615" as="geometry" />
        </mxCell>
        <mxCell id="47" parent="1" style="text;html=1;strokeColor=none;fillColor=#9C27B0;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=1;fontSize=24;fontFamily=Consolas;fontStyle=1;fontColor=#FFFFFF;" value="19" vertex="1">
          <mxGeometry height="45" width="60" x="480" y="610" as="geometry" />
        </mxCell>
        <mxCell id="48" parent="1" style="text;html=1;strokeColor=none;fillColor=#7B1FA2;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=1;fontSize=15;fontStyle=1;fontColor=#FFFFFF;" value="📌 x 的最终值" vertex="1">
          <mxGeometry height="30" width="130" x="70" y="668" as="geometry" />
        </mxCell>
        <mxCell id="49" parent="1" style="text;html=1;strokeColor=none;fillColor=#CE93D8;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=1;fontSize=22;fontFamily=Consolas;fontStyle=1;fontColor=#4A148C;" value="x = 6" vertex="1">
          <mxGeometry height="36" width="100" x="220" y="665" as="geometry" />
        </mxCell>
        <mxCell id="52" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=10;fontColor=#4CAF50;" value="x++ 结果" vertex="1">
          <mxGeometry height="15" width="55" x="247" y="650" as="geometry" />
        </mxCell>
        <mxCell id="53" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=10;fontColor=#2196F3;" value="++x 结果" vertex="1">
          <mxGeometry height="15" width="55" x="320" y="650" as="geometry" />
        </mxCell>
        <mxCell id="54" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=10;fontColor=#FF9800;" value="x-- 结果" vertex="1">
          <mxGeometry height="15" width="55" x="397" y="650" as="geometry" />
        </mxCell>
        <mxCell id="55" parent="1" style="text;html=1;strokeColor=none;fillColor=#E1BEE7;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=1;fontSize=12;fontStyle=1;fontColor=#6A1B9A;" value="x 变化轨迹" vertex="1">
          <mxGeometry height="25" width="80" x="600" y="113" as="geometry" />
        </mxCell>
        <mxCell id="56" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=16;fontFamily=Consolas;fontStyle=1;fontColor=#7B1FA2;" value="5 → 6 → 7 → 6" vertex="1">
          <mxGeometry height="30" width="140" x="690" y="110.5" as="geometry" />
        </mxCell>
      </root>
    </mxGraphModel>
  </diagram>
</mxfile>
// 验证代码
public class IncrementDemo {
    public static void main(String[] args) {
        int x = 5;
        int y = x++ + ++x + x--;

        System.out.println("y = " + y);  // 19
        System.out.println("x = " + x);  // 6
    }
}

字节码层面分析

// 源代码
int i = 1;
i = i++;

// 很多人认为结果是 2,但实际结果是 1!
<mxfile>
  <diagram id="bytecode-execution" name="字节码执行图解">
    <mxGraphModel dx="1068" dy="484" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="900" pageHeight="820" math="0" shadow="0">
      <root>
        <mxCell id="0" />
        <mxCell id="1" parent="0" />
        <mxCell id="2" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#FAFAFA;strokeColor=#1565C0;strokeWidth=3;arcSize=2;" value="" vertex="1">
          <mxGeometry height="780" width="860" x="20" y="20" as="geometry" />
        </mxCell>
        <mxCell id="3" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=22;fontStyle=1;fontColor=#1565C0;" value="使用 javap -c 查看字节码执行过程" vertex="1">
          <mxGeometry height="35" width="500" x="200" y="35" as="geometry" />
        </mxCell>
        <mxCell id="4" parent="1" style="line;strokeWidth=3;fillColor=none;align=left;verticalAlign=middle;spacingTop=-1;spacingLeft=3;spacingRight=3;rotatable=0;labelPosition=right;points=[];portConstraint=eastwest;strokeColor=#90CAF9;" value="" vertex="1">
          <mxGeometry height="10" width="800" x="50" y="75" as="geometry" />
        </mxCell>
        <mxCell id="5" parent="1" style="text;html=1;strokeColor=none;fillColor=#1976D2;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=1;fontSize=14;fontStyle=1;fontColor=#FFFFFF;" value="📋 字节码指令" vertex="1">
          <mxGeometry height="28" width="120" x="50" y="95" as="geometry" />
        </mxCell>
        <mxCell id="6" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#E3F2FD;strokeColor=#1976D2;strokeWidth=2;arcSize=5;" value="" vertex="1">
          <mxGeometry height="160" width="800" x="50" y="130" as="geometry" />
        </mxCell>
        <mxCell id="7" parent="1" style="text;html=1;strokeColor=none;fillColor=#BBDEFB;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=1;fontSize=13;fontFamily=Consolas;fontStyle=1;fontColor=#0D47A1;spacingLeft=8;" value="0: iconst_1" vertex="1">
          <mxGeometry height="24" width="100" x="70" y="142" as="geometry" />
        </mxCell>
        <mxCell id="8" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=12;fontColor=#1976D2;fontStyle=2;" value="// 将常量 1 压入栈" vertex="1">
          <mxGeometry height="24" width="150" x="180" y="142" as="geometry" />
        </mxCell>
        <mxCell id="9" parent="1" style="text;html=1;strokeColor=none;fillColor=#BBDEFB;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=1;fontSize=13;fontFamily=Consolas;fontStyle=1;fontColor=#0D47A1;spacingLeft=8;" value="1: istore_1" vertex="1">
          <mxGeometry height="24" width="100" x="70" y="170" as="geometry" />
        </mxCell>
        <mxCell id="10" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=12;fontColor=#1976D2;fontStyle=2;" value="// 存入局部变量表位置 1(i = 1)" vertex="1">
          <mxGeometry height="24" width="220" x="180" y="170" as="geometry" />
        </mxCell>
        <mxCell id="11" parent="1" style="text;html=1;strokeColor=none;fillColor=#C8E6C9;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=1;fontSize=13;fontFamily=Consolas;fontStyle=1;fontColor=#1B5E20;spacingLeft=8;" value="2: iload_1" vertex="1">
          <mxGeometry height="24" width="100" x="70" y="198" as="geometry" />
        </mxCell>
        <mxCell id="12" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=12;fontColor=#2E7D32;fontStyle=2;" value="// 将 i 的值(1)压入栈" vertex="1">
          <mxGeometry height="24" width="160" x="180" y="198" as="geometry" />
        </mxCell>
        <mxCell id="13" parent="1" style="text;html=1;strokeColor=none;fillColor=#A5D6A7;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=1;fontSize=11;fontColor=#1B5E20;fontStyle=1;spacingLeft=5;" value="← 这是赋值右边要用的值" vertex="1">
          <mxGeometry height="24" width="145" x="345" y="198" as="geometry" />
        </mxCell>
        <mxCell id="14" parent="1" style="text;html=1;strokeColor=none;fillColor=#FFE0B2;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=1;fontSize=13;fontFamily=Consolas;fontStyle=1;fontColor=#E65100;spacingLeft=8;" value="3: iinc 1, 1" vertex="1">
          <mxGeometry height="24" width="100" x="70" y="226" as="geometry" />
        </mxCell>
        <mxCell id="15" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=12;fontColor=#E65100;fontStyle=2;" value="// i 自增变成 2" vertex="1">
          <mxGeometry height="24" width="120" x="180" y="226" as="geometry" />
        </mxCell>
        <mxCell id="16" parent="1" style="text;html=1;strokeColor=none;fillColor=#FFCC80;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=1;fontSize=11;fontColor=#E65100;fontStyle=1;spacingLeft=5;" value="← 这是 i++ 的自增操作" vertex="1">
          <mxGeometry height="24" width="145" x="345" y="226" as="geometry" />
        </mxCell>
        <mxCell id="17" parent="1" style="text;html=1;strokeColor=none;fillColor=#FFCDD2;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=1;fontSize=13;fontFamily=Consolas;fontStyle=1;fontColor=#C62828;spacingLeft=8;" value="6: istore_1" vertex="1">
          <mxGeometry height="24" width="100" x="70" y="254" as="geometry" />
        </mxCell>
        <mxCell id="18" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=12;fontColor=#C62828;fontStyle=2;" value="// 将栈顶的 1 存回 i" vertex="1">
          <mxGeometry height="24" width="140" x="180" y="254" as="geometry" />
        </mxCell>
        <mxCell id="19" parent="1" style="text;html=1;strokeColor=none;fillColor=#EF9A9A;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=1;fontSize=11;fontColor=#B71C1C;fontStyle=1;spacingLeft=5;" value="← 覆盖了自增后的 2!" vertex="1">
          <mxGeometry height="24" width="145" x="345" y="254" as="geometry" />
        </mxCell>
        <mxCell id="20" parent="1" style="text;html=1;strokeColor=none;fillColor=#F44336;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=1;fontSize=16;fontFamily=Consolas;fontStyle=1;fontColor=#FFFFFF;" value="结果:i = 1" vertex="1">
          <mxGeometry height="35" width="130" x="690" y="185" as="geometry" />
        </mxCell>
        <mxCell id="21" parent="1" style="text;html=1;strokeColor=none;fillColor=#7B1FA2;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=1;fontSize=14;fontStyle=1;fontColor=#FFFFFF;" value="🔍 执行图解" vertex="1">
          <mxGeometry height="28" width="110" x="395" y="297" as="geometry" />
        </mxCell>
        <mxCell id="22" parent="1" style="text;html=1;strokeColor=none;fillColor=#9C27B0;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=1;fontSize=13;fontStyle=1;fontColor=#FFFFFF;" value="局部变量表" vertex="1">
          <mxGeometry height="26" width="100" x="80" y="330" as="geometry" />
        </mxCell>
        <mxCell id="23" parent="1" style="text;html=1;strokeColor=none;fillColor=#9C27B0;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=1;fontSize=13;fontStyle=1;fontColor=#FFFFFF;" value="操作数栈" vertex="1">
          <mxGeometry height="26" width="90" x="230" y="330" as="geometry" />
        </mxCell>
        <mxCell id="24" parent="1" style="text;html=1;strokeColor=none;fillColor=#9C27B0;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=1;fontSize=13;fontStyle=1;fontColor=#FFFFFF;" value="指令" vertex="1">
          <mxGeometry height="26" width="70" x="370" y="330" as="geometry" />
        </mxCell>
        <mxCell id="25" parent="1" style="text;html=1;strokeColor=none;fillColor=#9C27B0;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=1;fontSize=13;fontStyle=1;fontColor=#FFFFFF;" value="说明" vertex="1">
          <mxGeometry height="26" width="350" x="490" y="330" as="geometry" />
        </mxCell>
        <mxCell id="26" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#F3E5F5;strokeColor=#7B1FA2;strokeWidth=2;arcSize=5;" value="" vertex="1">
          <mxGeometry height="90" width="800" x="50" y="365" as="geometry" />
        </mxCell>
        <mxCell id="27" parent="1" style="text;html=1;strokeColor=none;fillColor=#CE93D8;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=1;fontSize=12;fontStyle=1;fontColor=#4A148C;" value="初始状态" vertex="1">
          <mxGeometry height="22" width="75" x="60" y="375" as="geometry" />
        </mxCell>
        <mxCell id="28" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#E1BEE7;strokeColor=#8E24AA;strokeWidth=1;" value="" vertex="1">
          <mxGeometry height="40" width="120" x="70" y="405" as="geometry" />
        </mxCell>
        <mxCell id="29" parent="1" style="text;html=1;strokeColor=none;fillColor=#BA68C8;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=1;fontSize=16;fontFamily=Consolas;fontStyle=1;fontColor=#FFFFFF;" value="1" vertex="1">
          <mxGeometry height="26" width="35" x="80" y="412" as="geometry" />
        </mxCell>
        <mxCell id="30" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=14;fontFamily=Consolas;fontStyle=1;fontColor=#6A1B9A;" value="i" vertex="1">
          <mxGeometry height="26" width="30" x="120" y="412" as="geometry" />
        </mxCell>
        <mxCell id="31" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#E1BEE7;strokeColor=#8E24AA;strokeWidth=1;strokeDasharray=3 3;" value="" vertex="1">
          <mxGeometry height="40" width="110" x="220" y="405" as="geometry" />
        </mxCell>
        <mxCell id="32" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=13;fontColor=#9C27B0;fontStyle=2;" value="空" vertex="1">
          <mxGeometry height="26" width="40" x="255" y="412" as="geometry" />
        </mxCell>
        <mxCell id="33" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=16;fontColor=#7B1FA2;fontStyle=1;" value="—" vertex="1">
          <mxGeometry height="40" width="70" x="370" y="405" as="geometry" />
        </mxCell>
        <mxCell id="34" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=13;fontColor=#6A1B9A;" value="i = 1 已初始化完成" vertex="1">
          <mxGeometry height="26" width="200" x="490" y="412" as="geometry" />
        </mxCell>
        <mxCell id="35" edge="1" parent="1" style="endArrow=classic;html=1;rounded=0;strokeWidth=2;strokeColor=#7B1FA2;entryX=0.5;entryY=0;entryDx=0;entryDy=0;" value="">
          <mxGeometry height="50" relative="1" width="50" as="geometry">
            <mxPoint x="130" y="455" as="sourcePoint" />
            <mxPoint x="130" y="485" as="targetPoint" />
          </mxGeometry>
        </mxCell>
        <mxCell id="36" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#E8F5E9;strokeColor=#4CAF50;strokeWidth=2;arcSize=5;" value="" vertex="1">
          <mxGeometry height="90" width="800" x="50" y="465" as="geometry" />
        </mxCell>
        <mxCell id="37" parent="1" style="text;html=1;strokeColor=none;fillColor=#81C784;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=1;fontSize=12;fontStyle=1;fontColor=#1B5E20;" value="步骤 1" vertex="1">
          <mxGeometry height="22" width="55" x="60" y="475" as="geometry" />
        </mxCell>
        <mxCell id="38" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#C8E6C9;strokeColor=#43A047;strokeWidth=1;" value="" vertex="1">
          <mxGeometry height="40" width="120" x="70" y="505" as="geometry" />
        </mxCell>
        <mxCell id="39" parent="1" style="text;html=1;strokeColor=none;fillColor=#66BB6A;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=1;fontSize=16;fontFamily=Consolas;fontStyle=1;fontColor=#FFFFFF;" value="1" vertex="1">
          <mxGeometry height="26" width="35" x="80" y="512" as="geometry" />
        </mxCell>
        <mxCell id="40" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=14;fontFamily=Consolas;fontStyle=1;fontColor=#2E7D32;" value="i" vertex="1">
          <mxGeometry height="26" width="30" x="120" y="512" as="geometry" />
        </mxCell>
        <mxCell id="41" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#C8E6C9;strokeColor=#43A047;strokeWidth=1;" value="" vertex="1">
          <mxGeometry height="40" width="110" x="220" y="505" as="geometry" />
        </mxCell>
        <mxCell id="42" parent="1" style="text;html=1;strokeColor=none;fillColor=#66BB6A;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=1;fontSize=16;fontFamily=Consolas;fontStyle=1;fontColor=#FFFFFF;" value="1" vertex="1">
          <mxGeometry height="26" width="35" x="257" y="512" as="geometry" />
        </mxCell>
        <mxCell id="43" parent="1" style="text;html=1;strokeColor=none;fillColor=#A5D6A7;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=1;fontSize=12;fontFamily=Consolas;fontStyle=1;fontColor=#1B5E20;" value="iload_1" vertex="1">
          <mxGeometry height="26" width="80" x="360" y="512" as="geometry" />
        </mxCell>
        <mxCell id="44" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=13;fontColor=#2E7D32;" value="将 i 的值(1)压入操作数栈" vertex="1">
          <mxGeometry height="26" width="200" x="490" y="512" as="geometry" />
        </mxCell>
        <mxCell id="45" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=16;" value="⬆️" vertex="1">
          <mxGeometry height="20" width="30" x="295" y="515" as="geometry" />
        </mxCell>
        <mxCell id="46" edge="1" parent="1" style="endArrow=classic;html=1;rounded=0;strokeWidth=2;strokeColor=#4CAF50;" value="">
          <mxGeometry height="50" relative="1" width="50" as="geometry">
            <mxPoint x="130" y="555" as="sourcePoint" />
            <mxPoint x="130" y="585" as="targetPoint" />
          </mxGeometry>
        </mxCell>
        <mxCell id="47" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#FFF3E0;strokeColor=#FF9800;strokeWidth=2;arcSize=5;" value="" vertex="1">
          <mxGeometry height="90" width="800" x="50" y="565" as="geometry" />
        </mxCell>
        <mxCell id="48" parent="1" style="text;html=1;strokeColor=none;fillColor=#FFB74D;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=1;fontSize=12;fontStyle=1;fontColor=#E65100;" value="步骤 2" vertex="1">
          <mxGeometry height="22" width="55" x="60" y="575" as="geometry" />
        </mxCell>
        <mxCell id="49" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#FFE0B2;strokeColor=#FB8C00;strokeWidth=1;" value="" vertex="1">
          <mxGeometry height="40" width="120" x="70" y="605" as="geometry" />
        </mxCell>
        <mxCell id="50" parent="1" style="text;html=1;strokeColor=none;fillColor=#FFA726;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=1;fontSize=16;fontFamily=Consolas;fontStyle=1;fontColor=#FFFFFF;" value="2" vertex="1">
          <mxGeometry height="26" width="35" x="80" y="612" as="geometry" />
        </mxCell>
        <mxCell id="51" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=14;fontFamily=Consolas;fontStyle=1;fontColor=#E65100;" value="i" vertex="1">
          <mxGeometry height="26" width="30" x="120" y="612" as="geometry" />
        </mxCell>
        <mxCell id="52" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#FFE0B2;strokeColor=#FB8C00;strokeWidth=1;" value="" vertex="1">
          <mxGeometry height="40" width="110" x="220" y="605" as="geometry" />
        </mxCell>
        <mxCell id="53" parent="1" style="text;html=1;strokeColor=none;fillColor=#FFA726;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=1;fontSize=16;fontFamily=Consolas;fontStyle=1;fontColor=#FFFFFF;" value="1" vertex="1">
          <mxGeometry height="26" width="35" x="257" y="612" as="geometry" />
        </mxCell>
        <mxCell id="54" parent="1" style="text;html=1;strokeColor=none;fillColor=#FFCC80;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=1;fontSize=12;fontFamily=Consolas;fontStyle=1;fontColor=#E65100;" value="iinc 1,1" vertex="1">
          <mxGeometry height="26" width="80" x="360" y="612" as="geometry" />
        </mxCell>
        <mxCell id="55" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=13;fontColor=#E65100;" value="i 在局部变量表中自增为 2,栈不变!" vertex="1">
          <mxGeometry height="26" width="260" x="490" y="612" as="geometry" />
        </mxCell>
        <mxCell id="56" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=14;fontColor=#E65100;" value="⬆️" vertex="1">
          <mxGeometry height="18" width="30" x="140" y="616" as="geometry" />
        </mxCell>
        <mxCell id="57" edge="1" parent="1" style="endArrow=classic;html=1;rounded=0;strokeWidth=2;strokeColor=#FF9800;" value="">
          <mxGeometry height="50" relative="1" width="50" as="geometry">
            <mxPoint x="130" y="655" as="sourcePoint" />
            <mxPoint x="130" y="685" as="targetPoint" />
          </mxGeometry>
        </mxCell>
        <mxCell id="58" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#FFEBEE;strokeColor=#F44336;strokeWidth=2;arcSize=5;" value="" vertex="1">
          <mxGeometry height="90" width="800" x="50" y="665" as="geometry" />
        </mxCell>
        <mxCell id="59" parent="1" style="text;html=1;strokeColor=none;fillColor=#EF5350;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=1;fontSize=12;fontStyle=1;fontColor=#FFFFFF;" value="步骤 3" vertex="1">
          <mxGeometry height="22" width="55" x="60" y="675" as="geometry" />
        </mxCell>
        <mxCell id="60" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#FFCDD2;strokeColor=#E53935;strokeWidth=1;" value="" vertex="1">
          <mxGeometry height="40" width="120" x="70" y="705" as="geometry" />
        </mxCell>
        <mxCell id="61" parent="1" style="text;html=1;strokeColor=none;fillColor=#EF5350;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=1;fontSize=16;fontFamily=Consolas;fontStyle=1;fontColor=#FFFFFF;" value="1" vertex="1">
          <mxGeometry height="26" width="35" x="80" y="712" as="geometry" />
        </mxCell>
        <mxCell id="62" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=14;fontFamily=Consolas;fontStyle=1;fontColor=#C62828;" value="i" vertex="1">
          <mxGeometry height="26" width="30" x="120" y="712" as="geometry" />
        </mxCell>
        <mxCell id="63" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#FFCDD2;strokeColor=#E53935;strokeWidth=1;strokeDasharray=3 3;" value="" vertex="1">
          <mxGeometry height="40" width="110" x="220" y="705" as="geometry" />
        </mxCell>
        <mxCell id="64" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=13;fontColor=#C62828;fontStyle=2;" value="空" vertex="1">
          <mxGeometry height="26" width="40" x="255" y="712" as="geometry" />
        </mxCell>
        <mxCell id="65" parent="1" style="text;html=1;strokeColor=none;fillColor=#EF9A9A;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=1;fontSize=12;fontFamily=Consolas;fontStyle=1;fontColor=#B71C1C;" value="istore_1" vertex="1">
          <mxGeometry height="26" width="80" x="360" y="712" as="geometry" />
        </mxCell>
        <mxCell id="66" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=13;fontColor=#C62828;fontStyle=1;" value="栈顶的 1 存回 i,覆盖了 2!" vertex="1">
          <mxGeometry height="26" width="200" x="490" y="712" as="geometry" />
        </mxCell>
        <mxCell id="67" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=14;fontColor=#C62828;" value="⬇️" vertex="1">
          <mxGeometry height="18" width="30" x="145" y="716" as="geometry" />
        </mxCell>
        <mxCell id="68" parent="1" style="text;html=1;strokeColor=none;fillColor=#F44336;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=1;fontSize=11;fontStyle=1;fontColor=#FFFFFF;" value="💥 覆盖" vertex="1">
          <mxGeometry height="20" width="55" x="145" y="675" as="geometry" />
        </mxCell>
        <mxCell id="69" parent="1" style="text;html=1;strokeColor=none;fillColor=#D32F2F;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=1;fontSize=14;fontStyle=1;fontColor=#FFFFFF;" value="🎯 最终结果" vertex="1">
          <mxGeometry height="28" width="110" x="700" y="140" as="geometry" />
        </mxCell>
      </root>
    </mxGraphModel>
  </diagram>
</mxfile>

3.3 移位运算符

<mxfile>
  <diagram id="shift-operators" name="移位运算符">
    <mxGraphModel dx="1068" dy="484" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="900" pageHeight="680" math="0" shadow="0">
      <root>
        <mxCell id="0" />
        <mxCell id="1" parent="0" />
        <mxCell id="2" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#FAFAFA;strokeColor=#1565C0;strokeWidth=3;arcSize=3;" value="" vertex="1">
          <mxGeometry height="650" width="860" x="20" y="20" as="geometry" />
        </mxCell>
        <mxCell id="3" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=26;fontStyle=1;fontColor=#1565C0;" value="移位运算符" vertex="1">
          <mxGeometry height="45" width="260" x="320" y="40" as="geometry" />
        </mxCell>
        <mxCell id="4" parent="1" style="line;strokeWidth=3;fillColor=none;align=left;verticalAlign=middle;spacingTop=-1;spacingLeft=3;spacingRight=3;rotatable=0;labelPosition=right;points=[];portConstraint=eastwest;strokeColor=#90CAF9;" value="" vertex="1">
          <mxGeometry height="10" width="800" x="50" y="90" as="geometry" />
        </mxCell>
        <mxCell id="5" parent="1" style="text;html=1;strokeColor=none;fillColor=#1976D2;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=1;fontSize=16;fontStyle=1;fontColor=#FFFFFF;" value="运算符" vertex="1">
          <mxGeometry height="40" width="120" x="50" y="115" as="geometry" />
        </mxCell>
        <mxCell id="6" parent="1" style="text;html=1;strokeColor=none;fillColor=#1976D2;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=1;fontSize=16;fontStyle=1;fontColor=#FFFFFF;" value="说明" vertex="1">
          <mxGeometry height="40" width="670" x="180" y="115" as="geometry" />
        </mxCell>
        <mxCell id="7" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#E8F5E9;strokeColor=#4CAF50;strokeWidth=2;arcSize=8;" value="" vertex="1">
          <mxGeometry height="115" width="800" x="50" y="165" as="geometry" />
        </mxCell>
        <mxCell id="8" parent="1" style="text;html=1;strokeColor=none;fillColor=#4CAF50;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=1;fontSize=28;fontFamily=Consolas;fontStyle=1;fontColor=#FFFFFF;" value="&lt;&lt;" vertex="1">
          <mxGeometry height="60" width="80" x="70" y="195" as="geometry" />
        </mxCell>
        <mxCell id="9" parent="1" style="text;html=1;strokeColor=none;fillColor=#A5D6A7;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=1;fontSize=18;fontStyle=1;fontColor=#1B5E20;" value="左移" vertex="1">
          <mxGeometry height="32" width="70" x="190" y="180" as="geometry" />
        </mxCell>
        <mxCell id="10" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=16;fontColor=#2E7D32;" value="低位补 0" vertex="1">
          <mxGeometry height="32" width="100" x="275" y="180" as="geometry" />
        </mxCell>
        <mxCell id="11" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=15;fontColor=#388E3C;" value="相当于" vertex="1">
          <mxGeometry height="28" width="60" x="190" y="225" as="geometry" />
        </mxCell>
        <mxCell id="12" parent="1" style="text;html=1;strokeColor=none;fillColor=#C8E6C9;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=1;fontSize=20;fontFamily=Consolas;fontStyle=1;fontColor=#1B5E20;" value="× 2ⁿ" vertex="1">
          <mxGeometry height="36" width="80" x="255" y="220" as="geometry" />
        </mxCell>
        <mxCell id="13" parent="1" style="text;html=1;strokeColor=none;fillColor=#A5D6A7;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=1;fontSize=14;fontFamily=Consolas;fontStyle=0;fontColor=#1B5E20;" value="示例:8 &lt;&lt; 2 = 32" vertex="1">
          <mxGeometry height="28" width="150" x="580" y="175" as="geometry" />
        </mxCell>
        <mxCell id="14" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=13;fontFamily=Consolas;fontColor=#2E7D32;" value="0000 1000 → 0010 0000" vertex="1">
          <mxGeometry height="24" width="210" x="550" y="208" as="geometry" />
        </mxCell>
        <mxCell id="15" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=12;fontColor=#4CAF50;fontStyle=2;" value="&amp;nbsp;补0" vertex="1">
          <mxGeometry height="24" width="35.5" x="708.25" y="245.5" as="geometry" />
        </mxCell>
        <mxCell id="16" parent="1" style="shape=curlyBracket;whiteSpace=wrap;html=1;rounded=1;flipH=1;labelPosition=right;verticalLabelPosition=middle;align=left;verticalAlign=middle;strokeColor=#4CAF50;strokeWidth=2;size=0.5;direction=north;" value="" vertex="1">
          <mxGeometry height="15" width="20" x="715" y="230.5" as="geometry" />
        </mxCell>
        <mxCell id="17" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#E3F2FD;strokeColor=#2196F3;strokeWidth=2;arcSize=6;" value="" vertex="1">
          <mxGeometry height="145" width="800" x="50" y="290" as="geometry" />
        </mxCell>
        <mxCell id="18" parent="1" style="text;html=1;strokeColor=none;fillColor=#2196F3;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=1;fontSize=28;fontFamily=Consolas;fontStyle=1;fontColor=#FFFFFF;" value="&gt;&gt;" vertex="1">
          <mxGeometry height="60" width="80" x="70" y="335" as="geometry" />
        </mxCell>
        <mxCell id="19" parent="1" style="text;html=1;strokeColor=none;fillColor=#90CAF9;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=1;fontSize=18;fontStyle=1;fontColor=#0D47A1;" value="带符号右移" vertex="1">
          <mxGeometry height="32" width="120" x="190" y="305" as="geometry" />
        </mxCell>
        <mxCell id="20" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=16;fontColor=#1565C0;" value="高位补符号位" vertex="1">
          <mxGeometry height="32" width="120" x="325" y="305" as="geometry" />
        </mxCell>
        <mxCell id="21" parent="1" style="text;html=1;strokeColor=none;fillColor=#BBDEFB;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=1;fontSize=14;fontColor=#1565C0;" value="正数补 0" vertex="1">
          <mxGeometry height="26" width="80" x="190" y="345" as="geometry" />
        </mxCell>
        <mxCell id="22" parent="1" style="text;html=1;strokeColor=none;fillColor=#BBDEFB;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=1;fontSize=14;fontColor=#1565C0;" value="负数补 1" vertex="1">
          <mxGeometry height="26" width="80" x="285" y="345" as="geometry" />
        </mxCell>
        <mxCell id="23" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=15;fontColor=#1976D2;" value="相当于" vertex="1">
          <mxGeometry height="28" width="60" x="190" y="380" as="geometry" />
        </mxCell>
        <mxCell id="24" parent="1" style="text;html=1;strokeColor=none;fillColor=#BBDEFB;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=1;fontSize=20;fontFamily=Consolas;fontStyle=1;fontColor=#0D47A1;" value="÷ 2ⁿ" vertex="1">
          <mxGeometry height="36" width="80" x="255" y="375" as="geometry" />
        </mxCell>
        <mxCell id="25" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=13;fontColor=#1976D2;fontStyle=2;" value="(向下取整)" vertex="1">
          <mxGeometry height="28" width="90" x="340" y="380" as="geometry" />
        </mxCell>
        <mxCell id="26" parent="1" style="text;html=1;strokeColor=none;fillColor=#90CAF9;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=1;fontSize=13;fontFamily=Consolas;fontColor=#0D47A1;" value="正数:32 &gt;&gt; 2 = 8" vertex="1">
          <mxGeometry height="26" width="145" x="580" y="305" as="geometry" />
        </mxCell>
        <mxCell id="27" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=12;fontFamily=Consolas;fontColor=#1565C0;" value="0010 0000 → 0000 1000" vertex="1">
          <mxGeometry height="17" width="195" x="555" y="340" as="geometry" />
        </mxCell>
        <mxCell id="28" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=right;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=11;fontColor=#2196F3;fontStyle=2;" value="补0→" vertex="1">
          <mxGeometry height="22" width="45" x="530" y="333" as="geometry" />
        </mxCell>
        <mxCell id="29" parent="1" style="text;html=1;strokeColor=none;fillColor=#90CAF9;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=1;fontSize=13;fontFamily=Consolas;fontColor=#0D47A1;" value="负数:-8 &gt;&gt; 2 = -2" vertex="1">
          <mxGeometry height="26" width="145" x="580" y="365" as="geometry" />
        </mxCell>
        <mxCell id="30" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=12;fontFamily=Consolas;fontColor=#1565C0;" value="1111 1000 → 1111 1110" vertex="1">
          <mxGeometry height="22" width="195" x="555" y="395" as="geometry" />
        </mxCell>
        <mxCell id="31" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=right;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=11;fontColor=#2196F3;fontStyle=2;" value="补1→" vertex="1">
          <mxGeometry height="22" width="45" x="530" y="393" as="geometry" />
        </mxCell>
        <mxCell id="32" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#FFF3E0;strokeColor=#FF9800;strokeWidth=2;arcSize=8;" value="" vertex="1">
          <mxGeometry height="120" width="800" x="50" y="465" as="geometry" />
        </mxCell>
        <mxCell id="33" parent="1" style="text;html=1;strokeColor=none;fillColor=#FF9800;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=1;fontSize=26;fontFamily=Consolas;fontStyle=1;fontColor=#FFFFFF;" value="&gt;&gt;&gt;" vertex="1">
          <mxGeometry height="60" width="80" x="70" y="495" as="geometry" />
        </mxCell>
        <mxCell id="34" parent="1" style="text;html=1;strokeColor=none;fillColor=#FFCC80;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=1;fontSize=18;fontStyle=1;fontColor=#E65100;" value="无符号右移" vertex="1">
          <mxGeometry height="32" width="120" x="190" y="480" as="geometry" />
        </mxCell>
        <mxCell id="35" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=16;fontColor=#E65100;" value="高位补 0" vertex="1">
          <mxGeometry height="32" width="100" x="325" y="480" as="geometry" />
        </mxCell>
        <mxCell id="36" parent="1" style="text;html=1;strokeColor=none;fillColor=#FFE0B2;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=1;fontSize=14;fontColor=#E65100;" value="不考虑符号位,全部补 0" vertex="1">
          <mxGeometry height="28" width="180" x="190" y="525" as="geometry" />
        </mxCell>
        <mxCell id="37" parent="1" style="text;html=1;strokeColor=none;fillColor=#FFCC80;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=1;fontSize=13;fontFamily=Consolas;fontColor=#E65100;" value="-8 &gt;&gt;&gt; 2 = 1073741822" vertex="1">
          <mxGeometry height="26" width="195" x="565" y="486" as="geometry" />
        </mxCell>
        <mxCell id="38" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=12;fontFamily=Consolas;fontColor=#E65100;" value="1111...1000 → 0011...1110" vertex="1">
          <mxGeometry height="22" width="200" x="565" y="516" as="geometry" />
        </mxCell>
        <mxCell id="39" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=right;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=11;fontColor=#FF9800;fontStyle=2;" value="补0→" vertex="1">
          <mxGeometry height="22" width="45" x="520" y="516" as="geometry" />
        </mxCell>
        <mxCell id="40" parent="1" style="text;html=1;strokeColor=none;fillColor=#FF9800;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=1;fontSize=12;fontStyle=1;fontColor=#FFFFFF;" value="负数变正数!" vertex="1">
          <mxGeometry height="24" width="95" x="617.5" y="550" as="geometry" />
        </mxCell>
        <mxCell id="41" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#FFEBEE;strokeColor=#F44336;strokeWidth=2;arcSize=12;" value="" vertex="1">
          <mxGeometry height="50" width="800" x="50" y="600" as="geometry" />
        </mxCell>
        <mxCell id="42" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=22;" value="⚠️" vertex="1">
          <mxGeometry height="35" width="40" x="70" y="608" as="geometry" />
        </mxCell>
        <mxCell id="43" parent="1" style="text;html=1;strokeColor=none;fillColor=#EF5350;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=1;fontSize=16;fontFamily=Consolas;fontStyle=1;fontColor=#FFFFFF;" value="没有 &lt;&lt;&lt; 运算符" vertex="1">
          <mxGeometry height="32" width="160" x="115" y="610" as="geometry" />
        </mxCell>
        <mxCell id="44" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=15;fontColor=#C62828;" value="因为左移无论正负都是低位补 0,不需要区分有无符号" vertex="1">
          <mxGeometry height="32" width="400" x="290" y="610" as="geometry" />
        </mxCell>
        <mxCell id="48" parent="1" style="text;html=1;strokeColor=none;fillColor=#E1BEE7;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=1;fontSize=12;fontStyle=1;fontColor=#7B1FA2;" value="移动方向" vertex="1">
          <mxGeometry height="24" width="70" x="460" y="175" as="geometry" />
        </mxCell>
        <mxCell id="49" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=24;fontColor=#4CAF50;fontStyle=1;" value="←" vertex="1">
          <mxGeometry height="35" width="70" x="460" y="200" as="geometry" />
        </mxCell>
        <mxCell id="50" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=24;fontColor=#2196F3;fontStyle=1;" value="→" vertex="1">
          <mxGeometry height="35" width="70" x="430" y="345" as="geometry" />
        </mxCell>
        <mxCell id="51" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=24;fontColor=#FF9800;fontStyle=1;" value="→" vertex="1">
          <mxGeometry height="35" width="70" x="420" y="505" as="geometry" />
        </mxCell>
      </root>
    </mxGraphModel>
  </diagram>
</mxfile>

左移运算 <<:

<mxfile>
    <mxGraphModel dx="1281" dy="581" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="900" pageHeight="720" math="0" shadow="0">
      <root>
        <mxCell id="0" />
        <mxCell id="1" parent="0" />
        <mxCell id="2" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#FAFAFA;strokeColor=#1565C0;strokeWidth=3;arcSize=3;" value="" vertex="1">
          <mxGeometry height="680" width="860" x="20" y="20" as="geometry" />
        </mxCell>
        <mxCell id="3" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=26;fontStyle=1;fontColor=#1565C0;" value="左移运算 &lt;&lt; 图解" vertex="1">
          <mxGeometry height="45" width="340" x="280" y="40" as="geometry" />
        </mxCell>
        <mxCell id="4" parent="1" style="line;strokeWidth=3;fillColor=none;align=left;verticalAlign=middle;spacingTop=-1;spacingLeft=3;spacingRight=3;rotatable=0;labelPosition=right;points=[];portConstraint=eastwest;strokeColor=#90CAF9;" value="" vertex="1">
          <mxGeometry height="10" width="800" x="50" y="90" as="geometry" />
        </mxCell>
        <mxCell id="5" parent="1" style="text;html=1;strokeColor=none;fillColor=#1976D2;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=1;fontSize=20;fontFamily=Consolas;fontStyle=1;fontColor=#FFFFFF;" value="示例:5 &lt;&lt; 2" vertex="1">
          <mxGeometry height="40" width="160" x="50" y="115" as="geometry" />
        </mxCell>
        <mxCell id="6" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=16;fontColor=#1976D2;" value="(5 左移 2 位)" vertex="1">
          <mxGeometry height="32" width="130" x="220" y="120" as="geometry" />
        </mxCell>
        <mxCell id="7" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=15;fontColor=#424242;" value="5 的二进制(int 32位,简化展示8位):" vertex="1">
          <mxGeometry height="28" width="300" x="50" y="175" as="geometry" />
        </mxCell>
        <mxCell id="8" parent="1" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#E3F2FD;strokeColor=#1976D2;strokeWidth=2;" value="" vertex="1">
          <mxGeometry height="60" width="60" x="100" y="215" as="geometry" />
        </mxCell>
        <mxCell id="9" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=24;fontFamily=Consolas;fontStyle=1;fontColor=#1565C0;" value="0" vertex="1">
          <mxGeometry height="60" width="60" x="100" y="215" as="geometry" />
        </mxCell>
        <mxCell id="10" parent="1" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#E3F2FD;strokeColor=#1976D2;strokeWidth=2;" value="" vertex="1">
          <mxGeometry height="60" width="60" x="160" y="215" as="geometry" />
        </mxCell>
        <mxCell id="11" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=24;fontFamily=Consolas;fontStyle=1;fontColor=#1565C0;" value="0" vertex="1">
          <mxGeometry height="60" width="60" x="160" y="215" as="geometry" />
        </mxCell>
        <mxCell id="12" parent="1" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#E3F2FD;strokeColor=#1976D2;strokeWidth=2;" value="" vertex="1">
          <mxGeometry height="60" width="60" x="220" y="215" as="geometry" />
        </mxCell>
        <mxCell id="13" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=24;fontFamily=Consolas;fontStyle=1;fontColor=#1565C0;" value="0" vertex="1">
          <mxGeometry height="60" width="60" x="220" y="215" as="geometry" />
        </mxCell>
        <mxCell id="14" parent="1" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#E3F2FD;strokeColor=#1976D2;strokeWidth=2;" value="" vertex="1">
          <mxGeometry height="60" width="60" x="280" y="215" as="geometry" />
        </mxCell>
        <mxCell id="15" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=24;fontFamily=Consolas;fontStyle=1;fontColor=#1565C0;" value="0" vertex="1">
          <mxGeometry height="60" width="60" x="280" y="215" as="geometry" />
        </mxCell>
        <mxCell id="16" parent="1" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#E3F2FD;strokeColor=#1976D2;strokeWidth=2;" value="" vertex="1">
          <mxGeometry height="60" width="60" x="340" y="215" as="geometry" />
        </mxCell>
        <mxCell id="17" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=24;fontFamily=Consolas;fontStyle=1;fontColor=#1565C0;" value="0" vertex="1">
          <mxGeometry height="60" width="60" x="340" y="215" as="geometry" />
        </mxCell>
        <mxCell id="18" parent="1" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#4CAF50;strokeColor=#2E7D32;strokeWidth=2;" value="" vertex="1">
          <mxGeometry height="60" width="60" x="400" y="215" as="geometry" />
        </mxCell>
        <mxCell id="19" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=24;fontFamily=Consolas;fontStyle=1;fontColor=#FFFFFF;" value="1" vertex="1">
          <mxGeometry height="60" width="60" x="400" y="215" as="geometry" />
        </mxCell>
        <mxCell id="20" parent="1" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#E3F2FD;strokeColor=#1976D2;strokeWidth=2;" value="" vertex="1">
          <mxGeometry height="60" width="60" x="460" y="215" as="geometry" />
        </mxCell>
        <mxCell id="21" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=24;fontFamily=Consolas;fontStyle=1;fontColor=#1565C0;" value="0" vertex="1">
          <mxGeometry height="60" width="60" x="460" y="215" as="geometry" />
        </mxCell>
        <mxCell id="22" parent="1" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#4CAF50;strokeColor=#2E7D32;strokeWidth=2;" value="" vertex="1">
          <mxGeometry height="60" width="60" x="520" y="215" as="geometry" />
        </mxCell>
        <mxCell id="23" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=24;fontFamily=Consolas;fontStyle=1;fontColor=#FFFFFF;" value="1" vertex="1">
          <mxGeometry height="60" width="60" x="520" y="215" as="geometry" />
        </mxCell>
        <mxCell id="24" parent="1" style="text;html=1;strokeColor=none;fillColor=#1976D2;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=1;fontSize=22;fontFamily=Consolas;fontStyle=1;fontColor=#FFFFFF;" value="= 5" vertex="1">
          <mxGeometry height="40" width="70" x="610" y="225" as="geometry" />
        </mxCell>
        <mxCell id="25" parent="1" style="text;html=1;strokeColor=none;fillColor=#FF9800;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=1;fontSize=18;fontStyle=1;fontColor=#FFFFFF;" value="左移 2 位:" vertex="1">
          <mxGeometry height="35" width="120" x="50" y="310" as="geometry" />
        </mxCell>
        <mxCell id="26" edge="1" parent="1" style="endArrow=classic;html=1;rounded=0;strokeWidth=3;strokeColor=#FF9800;entryX=0.5;entryY=0;entryDx=0;entryDy=0;" value="">
          <mxGeometry height="50" relative="1" width="50" as="geometry">
            <mxPoint x="540" y="310" as="sourcePoint" />
            <mxPoint x="540" y="380" as="targetPoint" />
          </mxGeometry>
        </mxCell>
        <mxCell id="27" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=18;fontFamily=Consolas;fontStyle=1;fontColor=#FF9800;" value="&lt;&lt; 2" vertex="1">
          <mxGeometry height="30" width="60" x="550" y="330" as="geometry" />
        </mxCell>
        <mxCell id="28" parent="1" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#E3F2FD;strokeColor=#1976D2;strokeWidth=2;" value="" vertex="1">
          <mxGeometry height="60" width="60" x="100" y="395" as="geometry" />
        </mxCell>
        <mxCell id="29" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=24;fontFamily=Consolas;fontStyle=1;fontColor=#1565C0;" value="0" vertex="1">
          <mxGeometry height="60" width="60" x="100" y="395" as="geometry" />
        </mxCell>
        <mxCell id="30" parent="1" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#E3F2FD;strokeColor=#1976D2;strokeWidth=2;" value="" vertex="1">
          <mxGeometry height="60" width="60" x="160" y="395" as="geometry" />
        </mxCell>
        <mxCell id="31" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=24;fontFamily=Consolas;fontStyle=1;fontColor=#1565C0;" value="0" vertex="1">
          <mxGeometry height="60" width="60" x="160" y="395" as="geometry" />
        </mxCell>
        <mxCell id="32" parent="1" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#E3F2FD;strokeColor=#1976D2;strokeWidth=2;" value="" vertex="1">
          <mxGeometry height="60" width="60" x="220" y="395" as="geometry" />
        </mxCell>
        <mxCell id="33" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=24;fontFamily=Consolas;fontStyle=1;fontColor=#1565C0;" value="0" vertex="1">
          <mxGeometry height="60" width="60" x="220" y="395" as="geometry" />
        </mxCell>
        <mxCell id="34" parent="1" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#4CAF50;strokeColor=#2E7D32;strokeWidth=2;" value="" vertex="1">
          <mxGeometry height="60" width="60" x="280" y="395" as="geometry" />
        </mxCell>
        <mxCell id="35" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=24;fontFamily=Consolas;fontStyle=1;fontColor=#FFFFFF;" value="1" vertex="1">
          <mxGeometry height="60" width="60" x="280" y="395" as="geometry" />
        </mxCell>
        <mxCell id="36" parent="1" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#E3F2FD;strokeColor=#1976D2;strokeWidth=2;" value="" vertex="1">
          <mxGeometry height="60" width="60" x="340" y="395" as="geometry" />
        </mxCell>
        <mxCell id="37" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=24;fontFamily=Consolas;fontStyle=1;fontColor=#1565C0;" value="0" vertex="1">
          <mxGeometry height="60" width="60" x="340" y="395" as="geometry" />
        </mxCell>
        <mxCell id="38" parent="1" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#4CAF50;strokeColor=#2E7D32;strokeWidth=2;" value="" vertex="1">
          <mxGeometry height="60" width="60" x="400" y="395" as="geometry" />
        </mxCell>
        <mxCell id="39" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=24;fontFamily=Consolas;fontStyle=1;fontColor=#FFFFFF;" value="1" vertex="1">
          <mxGeometry height="60" width="60" x="400" y="395" as="geometry" />
        </mxCell>
        <mxCell id="40" parent="1" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#FFCC80;strokeColor=#FF9800;strokeWidth=3;" value="" vertex="1">
          <mxGeometry height="60" width="60" x="460" y="395" as="geometry" />
        </mxCell>
        <mxCell id="41" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=24;fontFamily=Consolas;fontStyle=1;fontColor=#E65100;" value="0" vertex="1">
          <mxGeometry height="60" width="60" x="460" y="395" as="geometry" />
        </mxCell>
        <mxCell id="42" parent="1" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#FFCC80;strokeColor=#FF9800;strokeWidth=3;" value="" vertex="1">
          <mxGeometry height="60" width="60" x="520" y="395" as="geometry" />
        </mxCell>
        <mxCell id="43" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=24;fontFamily=Consolas;fontStyle=1;fontColor=#E65100;" value="0" vertex="1">
          <mxGeometry height="60" width="60" x="520" y="395" as="geometry" />
        </mxCell>
        <mxCell id="44" parent="1" style="text;html=1;strokeColor=none;fillColor=#4CAF50;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=1;fontSize=22;fontFamily=Consolas;fontStyle=1;fontColor=#FFFFFF;" value="= 20" vertex="1">
          <mxGeometry height="40" width="80" x="610" y="405" as="geometry" />
        </mxCell>
        <mxCell id="45" edge="1" parent="1" style="endArrow=classic;html=1;rounded=1;strokeWidth=2;strokeColor=#7B1FA2;curved=1;" value="">
          <mxGeometry height="50" relative="1" width="50" as="geometry">
            <Array as="points">
              <mxPoint x="350" y="310" />
            </Array>
            <mxPoint x="430" y="280" as="sourcePoint" />
            <mxPoint x="310" y="390" as="targetPoint" />
          </mxGeometry>
        </mxCell>
        <mxCell id="46" edge="1" parent="1" style="endArrow=classic;html=1;rounded=1;strokeWidth=2;strokeColor=#7B1FA2;curved=1;" value="">
          <mxGeometry height="50" relative="1" width="50" as="geometry">
            <Array as="points">
              <mxPoint x="470" y="310" />
            </Array>
            <mxPoint x="550" y="280" as="sourcePoint" />
            <mxPoint x="430" y="390" as="targetPoint" />
          </mxGeometry>
        </mxCell>
        <mxCell id="47" parent="1" style="text;html=1;strokeColor=none;fillColor=#E1BEE7;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=1;fontSize=13;fontStyle=1;fontColor=#7B1FA2;" value="原来的位左移" vertex="1">
          <mxGeometry height="28" width="110" x="710" y="310" as="geometry" />
        </mxCell>
        <mxCell id="48" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=20;fontColor=#FF9800;fontStyle=1;" value="↑" vertex="1">
          <mxGeometry height="30" width="60" x="460" y="455" as="geometry" />
        </mxCell>
        <mxCell id="49" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=20;fontColor=#FF9800;fontStyle=1;" value="↑" vertex="1">
          <mxGeometry height="30" width="60" x="520" y="455" as="geometry" />
        </mxCell>
        <mxCell id="50" parent="1" style="text;html=1;strokeColor=none;fillColor=#FFE0B2;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=1;fontSize=14;fontStyle=1;fontColor=#E65100;" value="低位补 0" vertex="1">
          <mxGeometry height="28" width="120" x="460" y="485" as="geometry" />
        </mxCell>
        <mxCell id="51" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#E8F5E9;strokeColor=#4CAF50;strokeWidth=2;arcSize=10;" value="" vertex="1">
          <mxGeometry height="70" width="800" x="50" y="540" as="geometry" />
        </mxCell>
        <mxCell id="52" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=18;fontStyle=1;fontColor=#2E7D32;" value="📐 数学公式:" vertex="1">
          <mxGeometry height="35" width="130" x="80" y="555" as="geometry" />
        </mxCell>
        <mxCell id="53" parent="1" style="text;html=1;strokeColor=none;fillColor=#A5D6A7;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=1;fontSize=22;fontFamily=Consolas;fontStyle=1;fontColor=#1B5E20;" value="5 × 2²" vertex="1">
          <mxGeometry height="42" width="100" x="220" y="552" as="geometry" />
        </mxCell>
        <mxCell id="54" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=22;fontStyle=1;fontColor=#2E7D32;" value="=" vertex="1">
          <mxGeometry height="35" width="40" x="330" y="555" as="geometry" />
        </mxCell>
        <mxCell id="55" parent="1" style="text;html=1;strokeColor=none;fillColor=#A5D6A7;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=1;fontSize=22;fontFamily=Consolas;fontStyle=1;fontColor=#1B5E20;" value="5 × 4" vertex="1">
          <mxGeometry height="42" width="100" x="380" y="552" as="geometry" />
        </mxCell>
        <mxCell id="56" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=22;fontStyle=1;fontColor=#2E7D32;" value="=" vertex="1">
          <mxGeometry height="35" width="40" x="490" y="555" as="geometry" />
        </mxCell>
        <mxCell id="57" parent="1" style="text;html=1;strokeColor=none;fillColor=#4CAF50;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=1;fontSize=24;fontFamily=Consolas;fontStyle=1;fontColor=#FFFFFF;" value="20" vertex="1">
          <mxGeometry height="45" width="70" x="540" y="550" as="geometry" />
        </mxCell>
        <mxCell id="58" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=28;fontStyle=1;fontColor=#4CAF50;" value="✓" vertex="1">
          <mxGeometry height="45" width="50" x="620" y="550" as="geometry" />
        </mxCell>
        <mxCell id="59" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#FFF3E0;strokeColor=#FF9800;strokeWidth=2;arcSize=10;" value="" vertex="1">
          <mxGeometry height="60" width="800" x="50" y="625" as="geometry" />
        </mxCell>
        <mxCell id="60" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=16;fontStyle=1;fontColor=#E65100;" value="💡 规律:" vertex="1">
          <mxGeometry height="32" width="80" x="80" y="638" as="geometry" />
        </mxCell>
        <mxCell id="61" parent="1" style="text;html=1;strokeColor=none;fillColor=#FFCC80;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=1;fontSize=18;fontFamily=Consolas;fontStyle=1;fontColor=#E65100;" value="左移 n 位 = 原数 × 2ⁿ" vertex="1">
          <mxGeometry height="38" width="240" x="170" y="635" as="geometry" />
        </mxCell>
        <mxCell id="62" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=14;fontColor=#F57C00;fontStyle=2;" value="(比乘法运算更快!)" vertex="1">
          <mxGeometry height="28" width="160" x="425" y="640" as="geometry" />
        </mxCell>
        <mxCell id="63" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=11;fontColor=#757575;" value="位索引" vertex="1">
          <mxGeometry height="20" width="45" x="50" y="275" as="geometry" />
        </mxCell>
        <mxCell id="64" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=11;fontColor=#757575;fontFamily=Consolas;" value="7" vertex="1">
          <mxGeometry height="20" width="60" x="100" y="275" as="geometry" />
        </mxCell>
        <mxCell id="65" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=11;fontColor=#757575;fontFamily=Consolas;" value="6" vertex="1">
          <mxGeometry height="20" width="60" x="160" y="275" as="geometry" />
        </mxCell>
        <mxCell id="66" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=11;fontColor=#757575;fontFamily=Consolas;" value="5" vertex="1">
          <mxGeometry height="20" width="60" x="220" y="275" as="geometry" />
        </mxCell>
        <mxCell id="67" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=11;fontColor=#757575;fontFamily=Consolas;" value="4" vertex="1">
          <mxGeometry height="20" width="60" x="280" y="275" as="geometry" />
        </mxCell>
        <mxCell id="68" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=11;fontColor=#757575;fontFamily=Consolas;" value="3" vertex="1">
          <mxGeometry height="20" width="60" x="340" y="275" as="geometry" />
        </mxCell>
        <mxCell id="69" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=11;fontColor=#757575;fontFamily=Consolas;" value="2" vertex="1">
          <mxGeometry height="20" width="60" x="400" y="275" as="geometry" />
        </mxCell>
        <mxCell id="70" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=11;fontColor=#757575;fontFamily=Consolas;" value="1" vertex="1">
          <mxGeometry height="20" width="60" x="460" y="275" as="geometry" />
        </mxCell>
        <mxCell id="71" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=11;fontColor=#757575;fontFamily=Consolas;" value="0" vertex="1">
          <mxGeometry height="20" width="60" x="520" y="275" as="geometry" />
        </mxCell>
      </root>
    </mxGraphModel>
  </diagram>
</mxfile>

带符号右移 >>

<mxfile>
  <diagram id="signed-right-shift" name="带符号右移图解">
    <mxGraphModel dx="1281" dy="581" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="900" pageHeight="1050" math="0" shadow="0">
      <root>
        <mxCell id="0" />
        <mxCell id="1" parent="0" />
        <mxCell id="2" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#FAFAFA;strokeColor=#1565C0;strokeWidth=3;arcSize=2;" value="" vertex="1">
          <mxGeometry height="730" width="860" x="20" y="20" as="geometry" />
        </mxCell>
        <mxCell id="3" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=26;fontStyle=1;fontColor=#1565C0;" value="带符号右移 &gt;&gt; 图解" vertex="1">
          <mxGeometry height="45" width="340" x="280" y="35" as="geometry" />
        </mxCell>
        <mxCell id="4" parent="1" style="line;strokeWidth=3;fillColor=none;align=left;verticalAlign=middle;spacingTop=-1;spacingLeft=3;spacingRight=3;rotatable=0;labelPosition=right;points=[];portConstraint=eastwest;strokeColor=#90CAF9;" value="" vertex="1">
          <mxGeometry height="10" width="800" x="50" y="85" as="geometry" />
        </mxCell>
        <mxCell id="5" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#E8F5E9;strokeColor=#4CAF50;strokeWidth=2;arcSize=4;" value="" vertex="1">
          <mxGeometry height="390" width="820" x="40" y="105" as="geometry" />
        </mxCell>
        <mxCell id="6" parent="1" style="text;html=1;strokeColor=none;fillColor=#4CAF50;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=1;fontSize=18;fontStyle=1;fontColor=#FFFFFF;" value="正数示例" vertex="1">
          <mxGeometry height="35" width="110" x="60" y="120" as="geometry" />
        </mxCell>
        <mxCell id="7" parent="1" style="text;html=1;strokeColor=none;fillColor=#A5D6A7;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=1;fontSize=20;fontFamily=Consolas;fontStyle=1;fontColor=#1B5E20;" value="20 &gt;&gt; 2" vertex="1">
          <mxGeometry height="40" width="120" x="185" y="118" as="geometry" />
        </mxCell>
        <mxCell id="8" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=15;fontColor=#2E7D32;" value="(20 右移 2 位)" vertex="1">
          <mxGeometry height="30" width="130" x="315" y="123" as="geometry" />
        </mxCell>
        <mxCell id="9" parent="1" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#C8E6C9;strokeColor=#4CAF50;strokeWidth=2;" value="" vertex="1">
          <mxGeometry height="55" width="55" x="120" y="175" as="geometry" />
        </mxCell>
        <mxCell id="10" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=22;fontFamily=Consolas;fontStyle=1;fontColor=#2E7D32;" value="0" vertex="1">
          <mxGeometry height="55" width="55" x="120" y="175" as="geometry" />
        </mxCell>
        <mxCell id="11" parent="1" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#E8F5E9;strokeColor=#4CAF50;strokeWidth=2;" value="" vertex="1">
          <mxGeometry height="55" width="55" x="175" y="175" as="geometry" />
        </mxCell>
        <mxCell id="12" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=22;fontFamily=Consolas;fontStyle=1;fontColor=#4CAF50;" value="0" vertex="1">
          <mxGeometry height="55" width="55" x="175" y="175" as="geometry" />
        </mxCell>
        <mxCell id="13" parent="1" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#E8F5E9;strokeColor=#4CAF50;strokeWidth=2;" value="" vertex="1">
          <mxGeometry height="55" width="55" x="230" y="175" as="geometry" />
        </mxCell>
        <mxCell id="14" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=22;fontFamily=Consolas;fontStyle=1;fontColor=#4CAF50;" value="0" vertex="1">
          <mxGeometry height="55" width="55" x="230" y="175" as="geometry" />
        </mxCell>
        <mxCell id="15" parent="1" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#81C784;strokeColor=#4CAF50;strokeWidth=2;" value="" vertex="1">
          <mxGeometry height="55" width="55" x="285" y="175" as="geometry" />
        </mxCell>
        <mxCell id="16" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=22;fontFamily=Consolas;fontStyle=1;fontColor=#FFFFFF;" value="1" vertex="1">
          <mxGeometry height="55" width="55" x="285" y="175" as="geometry" />
        </mxCell>
        <mxCell id="17" parent="1" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#E8F5E9;strokeColor=#4CAF50;strokeWidth=2;" value="" vertex="1">
          <mxGeometry height="55" width="55" x="340" y="175" as="geometry" />
        </mxCell>
        <mxCell id="18" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=22;fontFamily=Consolas;fontStyle=1;fontColor=#4CAF50;" value="0" vertex="1">
          <mxGeometry height="55" width="55" x="340" y="175" as="geometry" />
        </mxCell>
        <mxCell id="19" parent="1" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#81C784;strokeColor=#4CAF50;strokeWidth=2;" value="" vertex="1">
          <mxGeometry height="55" width="55" x="395" y="175" as="geometry" />
        </mxCell>
        <mxCell id="20" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=22;fontFamily=Consolas;fontStyle=1;fontColor=#FFFFFF;" value="1" vertex="1">
          <mxGeometry height="55" width="55" x="395" y="175" as="geometry" />
        </mxCell>
        <mxCell id="21" parent="1" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#FFCC80;strokeColor=#FF9800;strokeWidth=2;" value="" vertex="1">
          <mxGeometry height="55" width="55" x="450" y="175" as="geometry" />
        </mxCell>
        <mxCell id="22" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=22;fontFamily=Consolas;fontStyle=1;fontColor=#E65100;" value="0" vertex="1">
          <mxGeometry height="55" width="55" x="450" y="175" as="geometry" />
        </mxCell>
        <mxCell id="23" parent="1" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#FFCC80;strokeColor=#FF9800;strokeWidth=2;" value="" vertex="1">
          <mxGeometry height="55" width="55" x="505" y="175" as="geometry" />
        </mxCell>
        <mxCell id="24" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=22;fontFamily=Consolas;fontStyle=1;fontColor=#E65100;" value="0" vertex="1">
          <mxGeometry height="55" width="55" x="505" y="175" as="geometry" />
        </mxCell>
        <mxCell id="25" parent="1" style="text;html=1;strokeColor=none;fillColor=#4CAF50;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=1;fontSize=20;fontFamily=Consolas;fontStyle=1;fontColor=#FFFFFF;" value="= 20" vertex="1">
          <mxGeometry height="40" width="80" x="590" y="182" as="geometry" />
        </mxCell>
        <mxCell id="26" parent="1" style="text;html=1;strokeColor=none;fillColor=#FFE0B2;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=1;fontSize=12;fontStyle=1;fontColor=#E65100;" value="丢弃" vertex="1">
          <mxGeometry height="22" width="45" x="455" y="232" as="geometry" />
        </mxCell>
        <mxCell id="27" parent="1" style="text;html=1;strokeColor=none;fillColor=#FFE0B2;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=1;fontSize=12;fontStyle=1;fontColor=#E65100;" value="丢弃" vertex="1">
          <mxGeometry height="22" width="45" x="510" y="232" as="geometry" />
        </mxCell>
        <mxCell id="28" edge="1" parent="1" style="endArrow=classic;html=1;rounded=0;strokeWidth=3;strokeColor=#1976D2;" value="">
          <mxGeometry height="50" relative="1" width="50" as="geometry">
            <mxPoint x="340" y="270" as="sourcePoint" />
            <mxPoint x="340" y="320" as="targetPoint" />
          </mxGeometry>
        </mxCell>
        <mxCell id="29" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=16;fontFamily=Consolas;fontStyle=1;fontColor=#1976D2;" value="&gt;&gt; 2" vertex="1">
          <mxGeometry height="28" width="60" x="355" y="280" as="geometry" />
        </mxCell>
        <mxCell id="30" parent="1" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#BBDEFB;strokeColor=#1976D2;strokeWidth=3;" value="" vertex="1">
          <mxGeometry height="55" width="55" x="120" y="335" as="geometry" />
        </mxCell>
        <mxCell id="31" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=22;fontFamily=Consolas;fontStyle=1;fontColor=#1565C0;" value="0" vertex="1">
          <mxGeometry height="55" width="55" x="120" y="335" as="geometry" />
        </mxCell>
        <mxCell id="32" parent="1" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#BBDEFB;strokeColor=#1976D2;strokeWidth=3;" value="" vertex="1">
          <mxGeometry height="55" width="55" x="175" y="335" as="geometry" />
        </mxCell>
        <mxCell id="33" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=22;fontFamily=Consolas;fontStyle=1;fontColor=#1565C0;" value="0" vertex="1">
          <mxGeometry height="55" width="55" x="175" y="335" as="geometry" />
        </mxCell>
        <mxCell id="34" parent="1" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#E8F5E9;strokeColor=#4CAF50;strokeWidth=2;" value="" vertex="1">
          <mxGeometry height="55" width="55" x="230" y="335" as="geometry" />
        </mxCell>
        <mxCell id="35" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=22;fontFamily=Consolas;fontStyle=1;fontColor=#4CAF50;" value="0" vertex="1">
          <mxGeometry height="55" width="55" x="230" y="335" as="geometry" />
        </mxCell>
        <mxCell id="36" parent="1" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#E8F5E9;strokeColor=#4CAF50;strokeWidth=2;" value="" vertex="1">
          <mxGeometry height="55" width="55" x="285" y="335" as="geometry" />
        </mxCell>
        <mxCell id="37" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=22;fontFamily=Consolas;fontStyle=1;fontColor=#4CAF50;" value="0" vertex="1">
          <mxGeometry height="55" width="55" x="285" y="335" as="geometry" />
        </mxCell>
        <mxCell id="38" parent="1" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#E8F5E9;strokeColor=#4CAF50;strokeWidth=2;" value="" vertex="1">
          <mxGeometry height="55" width="55" x="340" y="335" as="geometry" />
        </mxCell>
        <mxCell id="39" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=22;fontFamily=Consolas;fontStyle=1;fontColor=#4CAF50;" value="0" vertex="1">
          <mxGeometry height="55" width="55" x="340" y="335" as="geometry" />
        </mxCell>
        <mxCell id="40" parent="1" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#81C784;strokeColor=#4CAF50;strokeWidth=2;" value="" vertex="1">
          <mxGeometry height="55" width="55" x="395" y="335" as="geometry" />
        </mxCell>
        <mxCell id="41" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=22;fontFamily=Consolas;fontStyle=1;fontColor=#FFFFFF;" value="1" vertex="1">
          <mxGeometry height="55" width="55" x="395" y="335" as="geometry" />
        </mxCell>
        <mxCell id="42" parent="1" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#E8F5E9;strokeColor=#4CAF50;strokeWidth=2;" value="" vertex="1">
          <mxGeometry height="55" width="55" x="450" y="335" as="geometry" />
        </mxCell>
        <mxCell id="43" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=22;fontFamily=Consolas;fontStyle=1;fontColor=#4CAF50;" value="0" vertex="1">
          <mxGeometry height="55" width="55" x="450" y="335" as="geometry" />
        </mxCell>
        <mxCell id="44" parent="1" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#81C784;strokeColor=#4CAF50;strokeWidth=2;" value="" vertex="1">
          <mxGeometry height="55" width="55" x="505" y="335" as="geometry" />
        </mxCell>
        <mxCell id="45" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=22;fontFamily=Consolas;fontStyle=1;fontColor=#FFFFFF;" value="1" vertex="1">
          <mxGeometry height="55" width="55" x="505" y="335" as="geometry" />
        </mxCell>
        <mxCell id="46" parent="1" style="text;html=1;strokeColor=none;fillColor=#1976D2;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=1;fontSize=20;fontFamily=Consolas;fontStyle=1;fontColor=#FFFFFF;" value="= 5" vertex="1">
          <mxGeometry height="40" width="80" x="590" y="342" as="geometry" />
        </mxCell>
        <mxCell id="47" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=18;fontColor=#1976D2;fontStyle=1;" value="↑" vertex="1">
          <mxGeometry height="25" width="55" x="120" y="390" as="geometry" />
        </mxCell>
        <mxCell id="48" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=18;fontColor=#1976D2;fontStyle=1;" value="↑" vertex="1">
          <mxGeometry height="25" width="55" x="175" y="390" as="geometry" />
        </mxCell>
        <mxCell id="49" parent="1" style="text;html=1;strokeColor=none;fillColor=#BBDEFB;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=1;fontSize=14;fontStyle=1;fontColor=#1565C0;" value="高位补符号位 0(正数)" vertex="1">
          <mxGeometry height="28" width="180" x="100" y="415" as="geometry" />
        </mxCell>
        <mxCell id="50" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#E3F2FD;strokeColor=#1976D2;strokeWidth=2;arcSize=8;" value="" vertex="1">
          <mxGeometry height="35" width="780" x="60" y="450" as="geometry" />
        </mxCell>
        <mxCell id="51" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=16;fontStyle=1;fontColor=#1565C0;" value="📐 数学公式: 20 ÷ 2² = 20 ÷ 4 = 5 ✓" vertex="1">
          <mxGeometry height="30" width="780" x="60" y="452" as="geometry" />
        </mxCell>
        <mxCell id="52" parent="1" style="line;strokeWidth=4;fillColor=none;align=left;verticalAlign=middle;spacingTop=-1;spacingLeft=3;spacingRight=3;rotatable=0;labelPosition=right;points=[];portConstraint=eastwest;strokeColor=#9E9E9E;dashed=1;dashPattern=8 8;" value="" vertex="1">
          <mxGeometry height="10" width="800" x="50" y="510" as="geometry" />
        </mxCell>
        <mxCell id="53" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#FFEBEE;strokeColor=#F44336;strokeWidth=2;arcSize=4;" value="" vertex="1">
          <mxGeometry height="195" width="820" x="40" y="535" as="geometry" />
        </mxCell>
        <mxCell id="54" parent="1" style="text;html=1;strokeColor=none;fillColor=#F44336;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=1;fontSize=18;fontStyle=1;fontColor=#FFFFFF;" value="负数示例" vertex="1">
          <mxGeometry height="35" width="110" x="60" y="550" as="geometry" />
        </mxCell>
        <mxCell id="55" parent="1" style="text;html=1;strokeColor=none;fillColor=#EF9A9A;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=1;fontSize=20;fontFamily=Consolas;fontStyle=1;fontColor=#B71C1C;" value="-8 &gt;&gt; 2" vertex="1">
          <mxGeometry height="40" width="120" x="185" y="548" as="geometry" />
        </mxCell>
        <mxCell id="56" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=15;fontColor=#C62828;" value="(-8 右移 2 位)" vertex="1">
          <mxGeometry height="30" width="130" x="315" y="553" as="geometry" />
        </mxCell>
        <mxCell id="57" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=14;fontColor=#757575;" value="-8 的补码(32位简化展示8位):" vertex="1">
          <mxGeometry height="25" width="250" x="60" y="600" as="geometry" />
        </mxCell>
        <mxCell id="58" parent="1" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#EF9A9A;strokeColor=#F44336;strokeWidth=2;" value="" vertex="1">
          <mxGeometry height="55" width="55" x="120" y="635" as="geometry" />
        </mxCell>
        <mxCell id="59" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=22;fontFamily=Consolas;fontStyle=1;fontColor=#B71C1C;" value="1" vertex="1">
          <mxGeometry height="55" width="55" x="120" y="635" as="geometry" />
        </mxCell>
        <mxCell id="60" parent="1" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#FFCDD2;strokeColor=#F44336;strokeWidth=2;" value="" vertex="1">
          <mxGeometry height="55" width="55" x="175" y="635" as="geometry" />
        </mxCell>
        <mxCell id="61" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=22;fontFamily=Consolas;fontStyle=1;fontColor=#C62828;" value="1" vertex="1">
          <mxGeometry height="55" width="55" x="175" y="635" as="geometry" />
        </mxCell>
        <mxCell id="62" parent="1" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#FFCDD2;strokeColor=#F44336;strokeWidth=2;" value="" vertex="1">
          <mxGeometry height="55" width="55" x="230" y="635" as="geometry" />
        </mxCell>
        <mxCell id="63" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=22;fontFamily=Consolas;fontStyle=1;fontColor=#C62828;" value="1" vertex="1">
          <mxGeometry height="55" width="55" x="230" y="635" as="geometry" />
        </mxCell>
        <mxCell id="64" parent="1" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#FFCDD2;strokeColor=#F44336;strokeWidth=2;" value="" vertex="1">
          <mxGeometry height="55" width="55" x="285" y="635" as="geometry" />
        </mxCell>
        <mxCell id="65" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=22;fontFamily=Consolas;fontStyle=1;fontColor=#C62828;" value="1" vertex="1">
          <mxGeometry height="55" width="55" x="285" y="635" as="geometry" />
        </mxCell>
        <mxCell id="66" parent="1" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#FFCDD2;strokeColor=#F44336;strokeWidth=2;" value="" vertex="1">
          <mxGeometry height="55" width="55" x="340" y="635" as="geometry" />
        </mxCell>
        <mxCell id="67" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=22;fontFamily=Consolas;fontStyle=1;fontColor=#C62828;" value="1" vertex="1">
          <mxGeometry height="55" width="55" x="340" y="635" as="geometry" />
        </mxCell>
        <mxCell id="68" parent="1" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#FFEBEE;strokeColor=#F44336;strokeWidth=2;" value="" vertex="1">
          <mxGeometry height="55" width="55" x="395" y="635" as="geometry" />
        </mxCell>
        <mxCell id="69" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=22;fontFamily=Consolas;fontStyle=1;fontColor=#E57373;" value="0" vertex="1">
          <mxGeometry height="55" width="55" x="395" y="635" as="geometry" />
        </mxCell>
        <mxCell id="70" parent="1" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#FFCC80;strokeColor=#FF9800;strokeWidth=2;" value="" vertex="1">
          <mxGeometry height="55" width="55" x="450" y="635" as="geometry" />
        </mxCell>
        <mxCell id="71" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=22;fontFamily=Consolas;fontStyle=1;fontColor=#E65100;" value="0" vertex="1">
          <mxGeometry height="55" width="55" x="450" y="635" as="geometry" />
        </mxCell>
        <mxCell id="72" parent="1" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#FFCC80;strokeColor=#FF9800;strokeWidth=2;" value="" vertex="1">
          <mxGeometry height="55" width="55" x="505" y="635" as="geometry" />
        </mxCell>
        <mxCell id="73" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=22;fontFamily=Consolas;fontStyle=1;fontColor=#E65100;" value="0" vertex="1">
          <mxGeometry height="55" width="55" x="505" y="635" as="geometry" />
        </mxCell>
        <mxCell id="74" parent="1" style="text;html=1;strokeColor=none;fillColor=#F44336;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=1;fontSize=20;fontFamily=Consolas;fontStyle=1;fontColor=#FFFFFF;" value="= -8" vertex="1">
          <mxGeometry height="40" width="80" x="590" y="642" as="geometry" />
        </mxCell>
      </root>
    </mxGraphModel>
  </diagram>
</mxfile>

无符号右移 >>>:

<mxfile>
    <mxGraphModel dx="2181" dy="581" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="900" pageHeight="850" math="0" shadow="0">
      <root>
        <mxCell id="0" />
        <mxCell id="1" parent="0" />
        <mxCell id="2" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#FAFAFA;strokeColor=#7B1FA2;strokeWidth=3;arcSize=2;" value="" vertex="1">
          <mxGeometry height="810" width="890" x="-10" y="20" as="geometry" />
        </mxCell>
        <mxCell id="3" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=26;fontStyle=1;fontColor=#7B1FA2;" value="无符号右移 &gt;&gt;&gt; 图解" vertex="1">
          <mxGeometry height="45" width="340" x="280" y="35" as="geometry" />
        </mxCell>
        <mxCell id="4" parent="1" style="line;strokeWidth=3;fillColor=none;align=left;verticalAlign=middle;spacingTop=-1;spacingLeft=3;spacingRight=3;rotatable=0;labelPosition=right;points=[];portConstraint=eastwest;strokeColor=#CE93D8;" value="" vertex="1">
          <mxGeometry height="10" width="800" x="50" y="85" as="geometry" />
        </mxCell>
        <mxCell id="5" parent="1" style="text;html=1;strokeColor=none;fillColor=#7B1FA2;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=1;fontSize=18;fontStyle=1;fontColor=#FFFFFF;" value="负数示例" vertex="1">
          <mxGeometry height="35" width="110" x="50" y="110" as="geometry" />
        </mxCell>
        <mxCell id="6" parent="1" style="text;html=1;strokeColor=none;fillColor=#E1BEE7;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=1;fontSize=20;fontFamily=Consolas;fontStyle=1;fontColor=#4A148C;" value="-8 &gt;&gt;&gt; 2" vertex="1">
          <mxGeometry height="40" width="140" x="175" y="108" as="geometry" />
        </mxCell>
        <mxCell id="7" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=15;fontColor=#7B1FA2;" value="(-8 无符号右移 2 位)" vertex="1">
          <mxGeometry height="30" width="180" x="325" y="113" as="geometry" />
        </mxCell>
        <mxCell id="8" parent="1" style="text;html=1;strokeColor=none;fillColor=#F3E5F5;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=1;fontSize=15;fontStyle=1;fontColor=#6A1B9A;" value="-8 的补码(完整32位):" vertex="1">
          <mxGeometry height="30" width="200" x="50" y="165" as="geometry" />
        </mxCell>
        <mxCell id="9" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#FFEBEE;strokeColor=#F44336;strokeWidth=2;arcSize=8;" value="" vertex="1">
          <mxGeometry height="90" width="800" x="50" y="205" as="geometry" />
        </mxCell>
        <mxCell id="10" parent="1" style="text;html=1;strokeColor=none;fillColor=#EF9A9A;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=1;fontSize=18;fontFamily=Consolas;fontStyle=1;fontColor=#B71C1C;" value="11111111" vertex="1">
          <mxGeometry height="40" width="110" x="70" y="225" as="geometry" />
        </mxCell>
        <mxCell id="11" parent="1" style="text;html=1;strokeColor=none;fillColor=#EF9A9A;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=1;fontSize=18;fontFamily=Consolas;fontStyle=1;fontColor=#B71C1C;" value="11111111" vertex="1">
          <mxGeometry height="40" width="110" x="195" y="225" as="geometry" />
        </mxCell>
        <mxCell id="12" parent="1" style="text;html=1;strokeColor=none;fillColor=#EF9A9A;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=1;fontSize=18;fontFamily=Consolas;fontStyle=1;fontColor=#B71C1C;" value="11111111" vertex="1">
          <mxGeometry height="40" width="110" x="320" y="225" as="geometry" />
        </mxCell>
        <mxCell id="13" parent="1" style="text;html=1;strokeColor=none;fillColor=#EF9A9A;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=1;fontSize=18;fontFamily=Consolas;fontStyle=1;fontColor=#B71C1C;" value="11111000" vertex="1">
          <mxGeometry height="40" width="110" x="445" y="225" as="geometry" />
        </mxCell>
        <mxCell id="14" parent="1" style="text;html=1;strokeColor=none;fillColor=#F44336;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=1;fontSize=18;fontFamily=Consolas;fontStyle=1;fontColor=#FFFFFF;" value="= -8" vertex="1">
          <mxGeometry height="40" width="70" x="580" y="225" as="geometry" />
        </mxCell>
        <mxCell id="15" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=12;fontColor=#C62828;" value="符号位=1(负数)" vertex="1">
          <mxGeometry height="22" width="130" x="60" y="265" as="geometry" />
        </mxCell>
        <mxCell id="16" parent="1" style="text;html=1;strokeColor=none;fillColor=#E1BEE7;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=1;fontSize=15;fontStyle=1;fontColor=#6A1B9A;" value="无符号右移 2 位(高位补 0):" vertex="1">
          <mxGeometry height="30" width="240" x="50" y="315" as="geometry" />
        </mxCell>
        <mxCell id="17" edge="1" parent="1" style="endArrow=classic;html=1;rounded=0;strokeWidth=3;strokeColor=#7B1FA2;" value="">
          <mxGeometry height="50" relative="1" width="50" as="geometry">
            <mxPoint x="430" y="310" as="sourcePoint" />
            <mxPoint x="430" y="360" as="targetPoint" />
          </mxGeometry>
        </mxCell>
        <mxCell id="18" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=16;fontFamily=Consolas;fontStyle=1;fontColor=#7B1FA2;" value="&gt;&gt;&gt; 2" vertex="1">
          <mxGeometry height="28" width="70" x="445" y="320" as="geometry" />
        </mxCell>
        <mxCell id="19" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#E8F5E9;strokeColor=#4CAF50;strokeWidth=2;arcSize=8;" value="" vertex="1">
          <mxGeometry height="90" width="800" x="50" y="365" as="geometry" />
        </mxCell>
        <mxCell id="20" parent="1" style="text;html=1;strokeColor=none;fillColor=#A5D6A7;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=1;fontSize=18;fontFamily=Consolas;fontStyle=1;fontColor=#1B5E20;" value="00111111" vertex="1">
          <mxGeometry height="40" width="110" x="70" y="385" as="geometry" />
        </mxCell>
        <mxCell id="21" parent="1" style="text;html=1;strokeColor=none;fillColor=#C8E6C9;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=1;fontSize=18;fontFamily=Consolas;fontStyle=1;fontColor=#2E7D32;" value="11111111" vertex="1">
          <mxGeometry height="40" width="110" x="195" y="385" as="geometry" />
        </mxCell>
        <mxCell id="22" parent="1" style="text;html=1;strokeColor=none;fillColor=#C8E6C9;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=1;fontSize=18;fontFamily=Consolas;fontStyle=1;fontColor=#2E7D32;" value="11111111" vertex="1">
          <mxGeometry height="40" width="110" x="320" y="385" as="geometry" />
        </mxCell>
        <mxCell id="23" parent="1" style="text;html=1;strokeColor=none;fillColor=#C8E6C9;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=1;fontSize=18;fontFamily=Consolas;fontStyle=1;fontColor=#2E7D32;" value="11111110" vertex="1">
          <mxGeometry height="40" width="110" x="445" y="385" as="geometry" />
        </mxCell>
        <mxCell id="24" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=20;fontColor=#1976D2;fontStyle=1;" value="↑" vertex="1">
          <mxGeometry height="25" width="25" x="70" y="425" as="geometry" />
        </mxCell>
        <mxCell id="25" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=20;fontColor=#1976D2;fontStyle=1;" value="↑" vertex="1">
          <mxGeometry height="25" width="25" x="85" y="425" as="geometry" />
        </mxCell>
        <mxCell id="26" parent="1" style="text;html=1;strokeColor=none;fillColor=#BBDEFB;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=1;fontSize=13;fontStyle=1;fontColor=#1565C0;" value="高位补 0(不考虑符号)" vertex="1">
          <mxGeometry height="24" width="170" x="115" y="427" as="geometry" />
        </mxCell>
        <mxCell id="27" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#E3F2FD;strokeColor=#1976D2;strokeWidth=2;arcSize=10;" value="" vertex="1">
          <mxGeometry height="70" width="800" x="50" y="475" as="geometry" />
        </mxCell>
        <mxCell id="28" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=18;fontStyle=1;fontColor=#1565C0;" value="📊 结果:" vertex="1">
          <mxGeometry height="35" width="90" x="80" y="492" as="geometry" />
        </mxCell>
        <mxCell id="29" parent="1" style="text;html=1;strokeColor=none;fillColor=#4CAF50;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=1;fontSize=24;fontFamily=Consolas;fontStyle=1;fontColor=#FFFFFF;" value="1073741822" vertex="1">
          <mxGeometry height="45" width="200" x="180" y="485" as="geometry" />
        </mxCell>
        <mxCell id="30" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=16;fontColor=#2E7D32;fontStyle=2;" value="(一个很大的正数!)" vertex="1">
          <mxGeometry height="35" width="180" x="395" y="492" as="geometry" />
        </mxCell>
        <mxCell id="31" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#FFF8E1;strokeColor=#FF8F00;strokeWidth=3;arcSize=8;" value="" vertex="1">
          <mxGeometry height="120" width="800" x="50" y="565" as="geometry" />
        </mxCell>
        <mxCell id="32" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=40;" value="⚠️" vertex="1">
          <mxGeometry height="60" width="60" x="70" y="590" as="geometry" />
        </mxCell>
        <mxCell id="33" parent="1" style="text;html=1;strokeColor=none;fillColor=#FF8F00;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=1;fontSize=20;fontStyle=1;fontColor=#FFFFFF;" value="重要警告" vertex="1">
          <mxGeometry height="40" width="120" x="140" y="580" as="geometry" />
        </mxCell>
        <mxCell id="34" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=18;fontStyle=1;fontColor=#E65100;" value="无符号右移会将负数变成正数!" vertex="1">
          <mxGeometry height="40" width="350" x="280" y="580" as="geometry" />
        </mxCell>
        <mxCell id="35" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=14;fontColor=#F57C00;" value="因为高位补 0 后,符号位变成了 0,数值被解释为正数" vertex="1">
          <mxGeometry height="30" width="450" x="140" y="625" as="geometry" />
        </mxCell>
        <mxCell id="36" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#F3E5F5;strokeColor=#9C27B0;strokeWidth=2;arcSize=8;" value="" vertex="1">
          <mxGeometry height="110" width="800" x="50" y="705" as="geometry" />
        </mxCell>
        <mxCell id="37" parent="1" style="text;html=1;strokeColor=none;fillColor=#9C27B0;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=1;fontSize=16;fontStyle=1;fontColor=#FFFFFF;" value="🔄 对比总结" vertex="1">
          <mxGeometry height="32" width="120" x="70" y="720" as="geometry" />
        </mxCell>
        <mxCell id="38" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#FFCDD2;strokeColor=#F44336;strokeWidth=2;" value="" vertex="1">
          <mxGeometry height="85" width="290" x="195" y="720" as="geometry" />
        </mxCell>
        <mxCell id="39" parent="1" style="text;html=1;strokeColor=none;fillColor=#F44336;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=1;fontSize=14;fontFamily=Consolas;fontStyle=1;fontColor=#FFFFFF;" value="&gt;&gt; 带符号右移" vertex="1">
          <mxGeometry height="28" width="130" x="210" y="727" as="geometry" />
        </mxCell>
        <mxCell id="40" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=16;fontFamily=Consolas;fontStyle=1;fontColor=#C62828;" value="-8 &gt;&gt; 2 = -2" vertex="1">
          <mxGeometry height="30" width="150" x="205" y="760" as="geometry" />
        </mxCell>
        <mxCell id="41" parent="1" style="text;html=1;strokeColor=none;fillColor=#FFCDD2;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=1;fontSize=12;fontColor=#B71C1C;" value="保持负数" vertex="1">
          <mxGeometry height="22" width="70" x="360" y="764" as="geometry" />
        </mxCell>
        <mxCell id="42" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#C8E6C9;strokeColor=#4CAF50;strokeWidth=2;" value="" vertex="1">
          <mxGeometry height="85" width="310" x="533" y="720" as="geometry" />
        </mxCell>
        <mxCell id="43" parent="1" style="text;html=1;strokeColor=none;fillColor=#4CAF50;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=1;fontSize=14;fontFamily=Consolas;fontStyle=1;fontColor=#FFFFFF;" value="&gt;&gt;&gt; 无符号右移" vertex="1">
          <mxGeometry height="25" width="150" x="548" y="727" as="geometry" />
        </mxCell>
        <mxCell id="44" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=14;fontFamily=Consolas;fontStyle=1;fontColor=#2E7D32;" value="-8 &gt;&gt;&gt; 2 = 1073741822" vertex="1">
          <mxGeometry height="30" width="220" x="543" y="760" as="geometry" />
        </mxCell>
        <mxCell id="45" parent="1" style="text;html=1;strokeColor=none;fillColor=#A5D6A7;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=1;fontSize=12;fontColor=#1B5E20;" value="变成正数" vertex="1">
          <mxGeometry height="22" width="70" x="763" y="764" as="geometry" />
        </mxCell>
        <mxCell id="46" parent="1" style="text;html=1;strokeColor=none;fillColor=#9C27B0;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=1;fontSize=14;fontStyle=1;fontColor=#FFFFFF;" value="VS" vertex="1">
          <mxGeometry height="28" width="35" x="491" y="749.5" as="geometry" />
        </mxCell>
        <mxCell id="47" edge="1" parent="1" source="48" style="endArrow=classic;html=1;rounded=1;strokeWidth=2;strokeColor=#F44336;curved=1;dashed=1;exitX=0.5;exitY=1;exitDx=0;exitDy=0;" value="">
          <mxGeometry height="50" relative="1" width="50" as="geometry">
            <Array as="points">
              <mxPoint y="320" />
            </Array>
            <mxPoint x="90" y="225" as="sourcePoint" />
            <mxPoint x="90" y="385" as="targetPoint" />
          </mxGeometry>
        </mxCell>
        <mxCell id="49" edge="1" parent="1" source="10" style="endArrow=classic;html=1;rounded=1;strokeWidth=2;strokeColor=#F44336;curved=1;dashed=1;exitX=0;exitY=0.5;exitDx=0;exitDy=0;" target="48" value="">
          <mxGeometry height="50" relative="1" width="50" as="geometry">
            <Array as="points" />
            <mxPoint x="70" y="245" as="sourcePoint" />
            <mxPoint x="90" y="385" as="targetPoint" />
          </mxGeometry>
        </mxCell>
        <mxCell id="48" parent="1" style="text;html=1;strokeColor=none;fillColor=#FFCDD2;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=1;fontSize=11;fontFamily=Consolas;fontStyle=1;fontColor=#C62828;" value="1→0" vertex="1">
          <mxGeometry height="20" width="40" y="295" as="geometry" />
        </mxCell>
      </root>
    </mxGraphModel>
  </diagram>
</mxfile>
// 移位运算验证代码
public class ShiftDemo {
    public static void main(String[] args) {
        // 左移
        System.out.println("5 << 2 = " + (5 << 2));   // 20
        System.out.println("1 << 3 = " + (1 << 3));   // 8

        // 带符号右移
        System.out.println("20 >> 2 = " + (20 >> 2));   // 5
        System.out.println("-8 >> 2 = " + (-8 >> 2));   // -2

        // 无符号右移
        System.out.println("-8 >>> 2 = " + (-8 >>> 2)); // 1073741822

        // 位数超出类型范围时取模
        System.out.println("1 << 32 = " + (1 << 32));   // 1 (32 % 32 = 0)
        System.out.println("1 << 33 = " + (1 << 33));   // 2 (33 % 32 = 1)
    }
}

源码中的移位运算应用

// ═══════════════════════════════════════════════════════════════════════
// HashMap 源码:计算哈希值
// ═══════════════════════════════════════════════════════════════════════
static final int hash(Object key) {
    int h;
    // 将 hashCode 的高 16 位与低 16 位异或
    // 目的:让高位也参与索引计算,减少哈希冲突
    return (key == null) ? 0 : (h = key.hashCode()) ^ (h >>> 16);
}

/*
 * 图解 hash 函数:
 *
 * 假设 hashCode = 0b 1010 1010 1010 1010 | 1100 1100 1100 1100
 *                    ─────────高16位──────  ─────────低16位──────
 *
 * h >>> 16:      0b 0000 0000 0000 0000 | 1010 1010 1010 1010
 *
 * h ^ (h>>>16):  0b 1010 1010 1010 1010 | 0110 0110 0110 0110
 *                                         ↑ 高低位信息混合
 */

// ═══════════════════════════════════════════════════════════════════════
// HashMap 源码:计算数组容量(取大于等于 cap 的最小 2 的幂)
// ═══════════════════════════════════════════════════════════════════════
static final int tableSizeFor(int cap) {
    int n = cap - 1;
    n |= n >>> 1;   // 将最高位的 1 右移,与原值或运算
    n |= n >>> 2;   // 继续扩展
    n |= n >>> 4;
    n |= n >>> 8;
    n |= n >>> 16;
    return (n < 0) ? 1 : (n >= MAXIMUM_CAPACITY) ? MAXIMUM_CAPACITY : n + 1;
}

/*
 * 图解(假设 cap = 10):
 *
 * n = 10 - 1 = 9 = 0b 0000 1001
 * n >>> 1         = 0b 0000 0100
 * n |= n >>> 1    = 0b 0000 1101
 * n >>> 2         = 0b 0000 0011
 * n |= n >>> 2    = 0b 0000 1111
 * ...
 * 最终 n = 15, n + 1 = 16 (2⁴)
 */

// ═══════════════════════════════════════════════════════════════════════
// 快速乘除 2 的幂次
// ═══════════════════════════════════════════════════════════════════════
int x = 10;
int multiply8 = x << 3;   // x * 8, 比 x * 8 更快
int divide4 = x >> 2;     // x / 4, 比 x / 4 更快

// ═══════════════════════════════════════════════════════════════════════
// 权限控制(位标志)
// ═══════════════════════════════════════════════════════════════════════
public class Permission {
    public static final int READ    = 1 << 0;  // 0001 = 1
    public static final int WRITE   = 1 << 1;  // 0010 = 2
    public static final int EXECUTE = 1 << 2;  // 0100 = 4
    public static final int DELETE  = 1 << 3;  // 1000 = 8

    private int permissions = 0;

    // 添加权限
    public void addPermission(int permission) {
        permissions |= permission;  // 0101 | 0010 = 0111
    }

    // 移除权限
    public void removePermission(int permission) {
        permissions &= ~permission;  // 0111 & 1101 = 0101
    }

    // 检查权限
    public boolean hasPermission(int permission) {
        return (permissions & permission) == permission;
    }

    public static void main(String[] args) {
        Permission p = new Permission();
        p.addPermission(READ | WRITE);  // 授予读写权限

        System.out.println(p.hasPermission(READ));    // true
        System.out.println(p.hasPermission(DELETE));  // false
    }
}

移位运算注意事项

<mxfile>
  <diagram id="shift-notes" name="移位运算注意事项">
    <mxGraphModel dx="1281" dy="581" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="900" pageHeight="1100" math="0" shadow="0">
      <root>
        <mxCell id="0" />
        <mxCell id="1" parent="0" />
        <mxCell id="2" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#FAFAFA;strokeColor=#455A64;strokeWidth=3;arcSize=2;" value="" vertex="1">
          <mxGeometry height="1060" width="860" x="20" y="20" as="geometry" />
        </mxCell>
        <mxCell id="3" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=28;fontStyle=1;fontColor=#37474F;" value="移位运算注意事项" vertex="1">
          <mxGeometry height="50" width="340" x="280" y="40" as="geometry" />
        </mxCell>
        <mxCell id="4" parent="1" style="line;strokeWidth=3;fillColor=none;align=left;verticalAlign=middle;spacingTop=-1;spacingLeft=3;spacingRight=3;rotatable=0;labelPosition=right;points=[];portConstraint=eastwest;strokeColor=#90A4AE;" value="" vertex="1">
          <mxGeometry height="10" width="800" x="50" y="95" as="geometry" />
        </mxCell>
        <mxCell id="5" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#E3F2FD;strokeColor=#1976D2;strokeWidth=2;arcSize=6;" value="" vertex="1">
          <mxGeometry height="210" width="820" x="40" y="120" as="geometry" />
        </mxCell>
        <mxCell id="6" parent="1" style="ellipse;whiteSpace=wrap;html=1;fillColor=#1976D2;strokeColor=none;fontColor=#FFFFFF;fontSize=20;fontStyle=1;" value="1" vertex="1">
          <mxGeometry height="40" width="40" x="60" y="135" as="geometry" />
        </mxCell>
        <mxCell id="7" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=20;fontStyle=1;fontColor=#1565C0;" value="移位位数会取模" vertex="1">
          <mxGeometry height="35" width="200" x="110" y="140" as="geometry" />
        </mxCell>
        <mxCell id="8" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#BBDEFB;strokeColor=#64B5F6;strokeWidth=2;arcSize=8;" value="" vertex="1">
          <mxGeometry height="130" width="380" x="60" y="185" as="geometry" />
        </mxCell>
        <mxCell id="9" parent="1" style="text;html=1;strokeColor=none;fillColor=#1976D2;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=1;fontSize=14;fontStyle=1;fontColor=#FFFFFF;" value="int (32位)" vertex="1">
          <mxGeometry height="28" width="90" x="75" y="217" as="geometry" />
        </mxCell>
        <mxCell id="10" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=14;fontFamily=Consolas;fontColor=#1565C0;" value="实际移位数 = 移位数 % 32" vertex="1">
          <mxGeometry height="28" width="250" x="175" y="217" as="geometry" />
        </mxCell>
        <mxCell id="11" parent="1" style="text;html=1;strokeColor=none;fillColor=#1976D2;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=1;fontSize=14;fontStyle=1;fontColor=#FFFFFF;" value="long (64位)" vertex="1">
          <mxGeometry height="28" width="90" x="75" y="255" as="geometry" />
        </mxCell>
        <mxCell id="12" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=14;fontFamily=Consolas;fontColor=#1565C0;" value="实际移位数 = 移位数 % 64" vertex="1">
          <mxGeometry height="28" width="250" x="175" y="255" as="geometry" />
        </mxCell>
        <mxCell id="13" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#E8F5E9;strokeColor=#4CAF50;strokeWidth=2;arcSize=8;" value="" vertex="1">
          <mxGeometry height="130" width="380" x="460" y="185" as="geometry" />
        </mxCell>
        <mxCell id="14" parent="1" style="text;html=1;strokeColor=none;fillColor=#4CAF50;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=1;fontSize=14;fontStyle=1;fontColor=#FFFFFF;" value="示例" vertex="1">
          <mxGeometry height="26" width="60" x="480" y="195" as="geometry" />
        </mxCell>
        <mxCell id="15" parent="1" style="text;html=1;strokeColor=none;fillColor=#C8E6C9;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=1;fontSize=15;fontFamily=Consolas;fontStyle=1;fontColor=#2E7D32;" value="1 &lt;&lt; 32" vertex="1">
          <mxGeometry height="30" width="90" x="480" y="235" as="geometry" />
        </mxCell>
        <mxCell id="16" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=13;fontColor=#666666;" value="等价于" vertex="1">
          <mxGeometry height="30" width="50" x="575" y="235" as="geometry" />
        </mxCell>
        <mxCell id="17" parent="1" style="text;html=1;strokeColor=none;fillColor=#C8E6C9;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=1;fontSize=15;fontFamily=Consolas;fontStyle=1;fontColor=#2E7D32;" value="1 &lt;&lt; 0" vertex="1">
          <mxGeometry height="30" width="80" x="630" y="235" as="geometry" />
        </mxCell>
        <mxCell id="18" parent="1" style="text;html=1;strokeColor=none;fillColor=#4CAF50;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=1;fontSize=15;fontFamily=Consolas;fontStyle=1;fontColor=#FFFFFF;" value="= 1" vertex="1">
          <mxGeometry height="30" width="50" x="720" y="235" as="geometry" />
        </mxCell>
        <mxCell id="19" parent="1" style="text;html=1;strokeColor=none;fillColor=#C8E6C9;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=1;fontSize=15;fontFamily=Consolas;fontStyle=1;fontColor=#2E7D32;" value="1 &lt;&lt; 33" vertex="1">
          <mxGeometry height="30" width="90" x="480" y="275" as="geometry" />
        </mxCell>
        <mxCell id="20" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=13;fontColor=#666666;" value="等价于" vertex="1">
          <mxGeometry height="30" width="50" x="575" y="275" as="geometry" />
        </mxCell>
        <mxCell id="21" parent="1" style="text;html=1;strokeColor=none;fillColor=#C8E6C9;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=1;fontSize=15;fontFamily=Consolas;fontStyle=1;fontColor=#2E7D32;" value="1 &lt;&lt; 1" vertex="1">
          <mxGeometry height="30" width="80" x="630" y="275" as="geometry" />
        </mxCell>
        <mxCell id="22" parent="1" style="text;html=1;strokeColor=none;fillColor=#4CAF50;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=1;fontSize=15;fontFamily=Consolas;fontStyle=1;fontColor=#FFFFFF;" value="= 2" vertex="1">
          <mxGeometry height="30" width="50" x="720" y="275" as="geometry" />
        </mxCell>
        <mxCell id="23" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#FFF3E0;strokeColor=#FF9800;strokeWidth=2;arcSize=6;" value="" vertex="1">
          <mxGeometry height="175" width="820" x="40" y="345" as="geometry" />
        </mxCell>
        <mxCell id="24" parent="1" style="ellipse;whiteSpace=wrap;html=1;fillColor=#FF9800;strokeColor=none;fontColor=#FFFFFF;fontSize=20;fontStyle=1;" value="2" vertex="1">
          <mxGeometry height="40" width="40" x="60" y="360" as="geometry" />
        </mxCell>
        <mxCell id="25" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=20;fontStyle=1;fontColor=#E65100;" value="类型提升" vertex="1">
          <mxGeometry height="35" width="150" x="110" y="365" as="geometry" />
        </mxCell>
        <mxCell id="26" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#FFE0B2;strokeColor=#FFB74D;strokeWidth=2;arcSize=8;" value="" vertex="1">
          <mxGeometry height="95" width="780" x="60" y="410" as="geometry" />
        </mxCell>
        <mxCell id="27" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=15;fontStyle=1;fontColor=#E65100;" value="byte、short、char 在移位前会先转换为 int" vertex="1">
          <mxGeometry height="28" width="400" x="80" y="420" as="geometry" />
        </mxCell>
        <mxCell id="28" parent="1" style="text;html=1;strokeColor=none;fillColor=#FFF8E1;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=1;fontSize=15;fontFamily=Consolas;fontColor=#795548;spacingLeft=10;" value="byte b = 1;" vertex="1">
          <mxGeometry height="35" width="150" x="80" y="455" as="geometry" />
        </mxCell>
        <mxCell id="29" parent="1" style="text;html=1;strokeColor=none;fillColor=#FFF8E1;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=1;fontSize=15;fontFamily=Consolas;fontColor=#795548;spacingLeft=10;" value="b &lt;&lt; 1" vertex="1">
          <mxGeometry height="35" width="100" x="250" y="455" as="geometry" />
        </mxCell>
        <mxCell id="30" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=20;fontColor=#FF9800;fontStyle=1;" value="→" vertex="1">
          <mxGeometry height="35" width="40" x="360" y="455" as="geometry" />
        </mxCell>
        <mxCell id="31" parent="1" style="text;html=1;strokeColor=none;fillColor=#FF9800;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=1;fontSize=15;fontStyle=1;fontColor=#FFFFFF;" value="结果是 int 类型" vertex="1">
          <mxGeometry height="35" width="150" x="410" y="455" as="geometry" />
        </mxCell>
        <mxCell id="32" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#FFEBEE;strokeColor=#F44336;strokeWidth=2;arcSize=6;" value="" vertex="1">
          <mxGeometry height="160" width="820" x="40" y="535" as="geometry" />
        </mxCell>
        <mxCell id="33" parent="1" style="ellipse;whiteSpace=wrap;html=1;fillColor=#F44336;strokeColor=none;fontColor=#FFFFFF;fontSize=20;fontStyle=1;" value="3" vertex="1">
          <mxGeometry height="40" width="40" x="60" y="550" as="geometry" />
        </mxCell>
        <mxCell id="34" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=20;fontStyle=1;fontColor=#C62828;" value="不支持浮点类型" vertex="1">
          <mxGeometry height="35" width="200" x="110" y="555" as="geometry" />
        </mxCell>
        <mxCell id="35" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#FFCDD2;strokeColor=#EF9A9A;strokeWidth=2;arcSize=8;" value="" vertex="1">
          <mxGeometry height="80" width="780" x="60" y="600" as="geometry" />
        </mxCell>
        <mxCell id="36" parent="1" style="text;html=1;strokeColor=none;fillColor=#FFEBEE;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=1;fontSize=15;fontFamily=Consolas;fontColor=#795548;spacingLeft=10;" value="float f = 1.0f;" vertex="1">
          <mxGeometry height="35" width="170" x="85" y="622.5" as="geometry" />
        </mxCell>
        <mxCell id="37" parent="1" style="text;html=1;strokeColor=none;fillColor=#FFEBEE;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=1;fontSize=15;fontFamily=Consolas;fontColor=#795548;spacingLeft=10;" value="f &lt;&lt; 1;" vertex="1">
          <mxGeometry height="35" width="100" x="275" y="622.5" as="geometry" />
        </mxCell>
        <mxCell id="38" parent="1" style="text;html=1;strokeColor=none;fillColor=#F44336;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=1;fontSize=16;fontStyle=1;fontColor=#FFFFFF;" value="❌ 编译错误" vertex="1">
          <mxGeometry height="35" width="130" x="415" y="622.5" as="geometry" />
        </mxCell>
        <mxCell id="39" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#E8F5E9;strokeColor=#4CAF50;strokeWidth=2;arcSize=6;" value="" vertex="1">
          <mxGeometry height="220" width="820" x="40" y="710" as="geometry" />
        </mxCell>
        <mxCell id="40" parent="1" style="ellipse;whiteSpace=wrap;html=1;fillColor=#4CAF50;strokeColor=none;fontColor=#FFFFFF;fontSize=20;fontStyle=1;" value="4" vertex="1">
          <mxGeometry height="40" width="40" x="60" y="725" as="geometry" />
        </mxCell>
        <mxCell id="41" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=20;fontStyle=1;fontColor=#2E7D32;" value="移位 vs 乘除" vertex="1">
          <mxGeometry height="35" width="180" x="110" y="730" as="geometry" />
        </mxCell>
        <mxCell id="42" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#C8E6C9;strokeColor=#81C784;strokeWidth=2;arcSize=8;" value="" vertex="1">
          <mxGeometry height="140" width="780" x="60" y="775" as="geometry" />
        </mxCell>
        <mxCell id="43" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=28;" value="⚡" vertex="1">
          <mxGeometry height="40" width="40" x="80" y="790" as="geometry" />
        </mxCell>
        <mxCell id="44" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=15;fontStyle=1;fontColor=#2E7D32;" value="移位更快,但可读性较差" vertex="1">
          <mxGeometry height="30" width="250" x="125" y="795" as="geometry" />
        </mxCell>
        <mxCell id="45" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=28;" value="🔧" vertex="1">
          <mxGeometry height="40" width="40" x="80" y="830" as="geometry" />
        </mxCell>
        <mxCell id="46" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=15;fontStyle=1;fontColor=#2E7D32;" value="现代 JIT 编译器会自动优化乘除 2 的幂次为移位" vertex="1">
          <mxGeometry height="30" width="420" x="125" y="835" as="geometry" />
        </mxCell>
        <mxCell id="47" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=28;" value="💡" vertex="1">
          <mxGeometry height="40" width="40" x="80" y="870" as="geometry" />
        </mxCell>
        <mxCell id="48" parent="1" style="text;html=1;strokeColor=none;fillColor=#4CAF50;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=1;fontSize=14;fontStyle=1;fontColor=#FFFFFF;" value="建议:" vertex="1">
          <mxGeometry height="28" width="60" x="125" y="875" as="geometry" />
        </mxCell>
        <mxCell id="49" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=15;fontStyle=1;fontColor=#2E7D32;" value="除非性能关键场景,否则用乘除更清晰" vertex="1">
          <mxGeometry height="30" width="350" x="195" y="872" as="geometry" />
        </mxCell>
        <mxCell id="50" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#E1BEE7;strokeColor=#9C27B0;strokeWidth=2;arcSize=10;" value="" vertex="1">
          <mxGeometry height="120" width="820" x="40" y="945" as="geometry" />
        </mxCell>
        <mxCell id="51" parent="1" style="text;html=1;strokeColor=none;fillColor=#9C27B0;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=1;fontSize=16;fontStyle=1;fontColor=#FFFFFF;" value="📝 总结对比" vertex="1">
          <mxGeometry height="32" width="120" x="60" y="960" as="geometry" />
        </mxCell>
        <mxCell id="52" parent="1" style="text;html=1;strokeColor=none;fillColor=#CE93D8;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=1;fontSize=16;fontFamily=Consolas;fontStyle=1;fontColor=#4A148C;" value="n &lt;&lt; k" vertex="1">
          <mxGeometry height="32" width="90" x="200" y="960" as="geometry" />
        </mxCell>
        <mxCell id="53" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=20;fontColor=#7B1FA2;fontStyle=1;" value="≈" vertex="1">
          <mxGeometry height="35" width="30" x="295" y="958" as="geometry" />
        </mxCell>
        <mxCell id="54" parent="1" style="text;html=1;strokeColor=none;fillColor=#CE93D8;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=1;fontSize=16;fontFamily=Consolas;fontStyle=1;fontColor=#4A148C;" value="n × 2ᵏ" vertex="1">
          <mxGeometry height="32" width="90" x="330" y="960" as="geometry" />
        </mxCell>
        <mxCell id="55" parent="1" style="text;html=1;strokeColor=none;fillColor=#CE93D8;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=1;fontSize=16;fontFamily=Consolas;fontStyle=1;fontColor=#4A148C;" value="n &gt;&gt; k" vertex="1">
          <mxGeometry height="32" width="90" x="480" y="960" as="geometry" />
        </mxCell>
        <mxCell id="56" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=20;fontColor=#7B1FA2;fontStyle=1;" value="≈" vertex="1">
          <mxGeometry height="35" width="30" x="575" y="958" as="geometry" />
        </mxCell>
        <mxCell id="57" parent="1" style="text;html=1;strokeColor=none;fillColor=#CE93D8;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=1;fontSize=16;fontFamily=Consolas;fontStyle=1;fontColor=#4A148C;" value="n ÷ 2ᵏ" vertex="1">
          <mxGeometry height="32" width="90" x="610" y="960" as="geometry" />
        </mxCell>
        <mxCell id="58" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=12;fontColor=#7B1FA2;" value="(向下取整)" vertex="1">
          <mxGeometry height="32" width="90" x="705" y="960" as="geometry" />
        </mxCell>
        <mxCell id="59" parent="1" style="text;html=1;strokeColor=none;fillColor=#F3E5F5;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=1;fontSize=14;fontStyle=1;fontColor=#6A1B9A;" value="✅ 移位运算只适用于整数类型:byte、short、int、long、char" vertex="1">
          <mxGeometry height="35" width="600" x="150" y="1010" as="geometry" />
        </mxCell>
      </root>
    </mxGraphModel>
  </diagram>
</mxfile>

四、流程控制

4.1 流程控制分类

<mxfile>
  <diagram id="java-flow-control" name="Java流程控制分类">
    <mxGraphModel dx="1281" dy="581" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="900" pageHeight="750" math="0" shadow="0">
      <root>
        <mxCell id="0" />
        <mxCell id="1" parent="0" />
        <mxCell id="2" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#FAFAFA;strokeColor=#5C6BC0;strokeWidth=3;arcSize=2;" value="" vertex="1">
          <mxGeometry height="710" width="860" x="20" y="20" as="geometry" />
        </mxCell>
        <mxCell id="3" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=26;fontStyle=1;fontColor=#3949AB;" value="Java 流程控制分类" vertex="1">
          <mxGeometry height="45" width="320" x="290" y="40" as="geometry" />
        </mxCell>
        <mxCell id="4" parent="1" style="line;strokeWidth=3;fillColor=none;align=left;verticalAlign=middle;spacingTop=-1;spacingLeft=3;spacingRight=3;rotatable=0;labelPosition=right;points=[];portConstraint=eastwest;strokeColor=#9FA8DA;" value="" vertex="1">
          <mxGeometry height="10" width="800" x="50" y="90" as="geometry" />
        </mxCell>
        <mxCell id="5" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#3949AB;strokeColor=#1A237E;strokeWidth=2;fontSize=20;fontStyle=1;fontColor=#FFFFFF;shadow=1;" value="流程控制" vertex="1">
          <mxGeometry height="60" width="170" x="365" y="120" as="geometry" />
        </mxCell>
        <mxCell id="6" edge="1" parent="1" source="5" style="edgeStyle=orthogonalEdgeStyle;rounded=1;orthogonalLoop=1;jettySize=auto;html=1;strokeWidth=3;strokeColor=#3949AB;endArrow=classic;endFill=1;" target="8" value="">
          <mxGeometry relative="1" as="geometry" />
        </mxCell>
        <mxCell id="7" edge="1" parent="1" source="5" style="edgeStyle=orthogonalEdgeStyle;rounded=1;orthogonalLoop=1;jettySize=auto;html=1;strokeWidth=3;strokeColor=#3949AB;endArrow=classic;endFill=1;" target="12" value="">
          <mxGeometry relative="1" as="geometry" />
        </mxCell>
        <mxCell id="9" edge="1" parent="1" source="5" style="edgeStyle=orthogonalEdgeStyle;rounded=1;orthogonalLoop=1;jettySize=auto;html=1;strokeWidth=3;strokeColor=#3949AB;endArrow=classic;endFill=1;" target="17" value="">
          <mxGeometry relative="1" as="geometry" />
        </mxCell>
        <mxCell id="8" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#E3F2FD;strokeColor=#1976D2;strokeWidth=2;arcSize=8;" value="" vertex="1">
          <mxGeometry height="180" width="220" x="60" y="240" as="geometry" />
        </mxCell>
        <mxCell id="10" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#1976D2;strokeColor=#0D47A1;strokeWidth=2;fontSize=18;fontStyle=1;fontColor=#FFFFFF;" value="顺序结构" vertex="1">
          <mxGeometry height="45" width="150" x="95" y="255" as="geometry" />
        </mxCell>
        <mxCell id="11" parent="1" style="text;html=1;strokeColor=none;fillColor=#BBDEFB;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=1;fontSize=16;fontColor=#1565C0;spacing=8;" value="代码从上到下&lt;br&gt;依次执行" vertex="1">
          <mxGeometry height="80" width="180" x="80" y="320" as="geometry" />
        </mxCell>
        <mxCell id="12" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#FFF3E0;strokeColor=#FF9800;strokeWidth=2;arcSize=8;" value="" vertex="1">
          <mxGeometry height="180" width="220" x="340" y="240" as="geometry" />
        </mxCell>
        <mxCell id="13" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#FF9800;strokeColor=#E65100;strokeWidth=2;fontSize=18;fontStyle=1;fontColor=#FFFFFF;" value="分支结构" vertex="1">
          <mxGeometry height="45" width="150" x="375" y="255" as="geometry" />
        </mxCell>
        <mxCell id="14" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#FFE0B2;strokeColor=#FFB74D;fontSize=15;fontFamily=Consolas;fontStyle=1;fontColor=#E65100;" value="if - else" vertex="1">
          <mxGeometry height="40" width="170" x="365" y="320" as="geometry" />
        </mxCell>
        <mxCell id="15" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#FFE0B2;strokeColor=#FFB74D;fontSize=15;fontFamily=Consolas;fontStyle=1;fontColor=#E65100;" value="switch" vertex="1">
          <mxGeometry height="40" width="170" x="365" y="370" as="geometry" />
        </mxCell>
        <mxCell id="17" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#E8F5E9;strokeColor=#4CAF50;strokeWidth=2;arcSize=8;" value="" vertex="1">
          <mxGeometry height="190" width="220" x="620" y="240" as="geometry" />
        </mxCell>
        <mxCell id="18" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#4CAF50;strokeColor=#1B5E20;strokeWidth=2;fontSize=18;fontStyle=1;fontColor=#FFFFFF;" value="循环结构" vertex="1">
          <mxGeometry height="45" width="150" x="655" y="255" as="geometry" />
        </mxCell>
        <mxCell id="19" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#C8E6C9;strokeColor=#81C784;fontSize=15;fontFamily=Consolas;fontStyle=1;fontColor=#2E7D32;" value="for" vertex="1">
          <mxGeometry height="32" width="170" x="645" y="310" as="geometry" />
        </mxCell>
        <mxCell id="20" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#C8E6C9;strokeColor=#81C784;fontSize=15;fontFamily=Consolas;fontStyle=1;fontColor=#2E7D32;" value="while" vertex="1">
          <mxGeometry height="32" width="170" x="645" y="350" as="geometry" />
        </mxCell>
        <mxCell id="21" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#C8E6C9;strokeColor=#81C784;fontSize=15;fontFamily=Consolas;fontStyle=1;fontColor=#2E7D32;" value="do-while" vertex="1">
          <mxGeometry height="32" width="170" x="645" y="390" as="geometry" />
        </mxCell>
        <mxCell id="22" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#F3E5F5;strokeColor=#9C27B0;strokeWidth=3;arcSize=6;" value="" vertex="1">
          <mxGeometry height="250" width="780" x="60" y="460" as="geometry" />
        </mxCell>
        <mxCell id="23" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#9C27B0;strokeColor=#6A1B9A;strokeWidth=2;fontSize=20;fontStyle=1;fontColor=#FFFFFF;shadow=1;" value="跳转语句" vertex="1">
          <mxGeometry height="50" width="170" x="365" y="480" as="geometry" />
        </mxCell>
        <mxCell id="24" parent="1" style="line;strokeWidth=2;fillColor=none;align=left;verticalAlign=middle;spacingTop=-1;spacingLeft=3;spacingRight=3;rotatable=0;labelPosition=right;points=[];portConstraint=eastwest;strokeColor=#CE93D8;" value="" vertex="1">
          <mxGeometry height="10" width="700" x="100" y="545" as="geometry" />
        </mxCell>
        <mxCell id="25" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#FFEBEE;strokeColor=#F44336;strokeWidth=2;arcSize=10;" value="" vertex="1">
          <mxGeometry height="120" width="220" x="90" y="570" as="geometry" />
        </mxCell>
        <mxCell id="26" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#F44336;strokeColor=#C62828;fontSize=18;fontFamily=Consolas;fontStyle=1;fontColor=#FFFFFF;" value="break" vertex="1">
          <mxGeometry height="40" width="140" x="130" y="585" as="geometry" />
        </mxCell>
        <mxCell id="27" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=14;fontColor=#C62828;" value="跳出当前循环&lt;br&gt;或 switch" vertex="1">
          <mxGeometry height="45" width="180" x="110" y="635" as="geometry" />
        </mxCell>
        <mxCell id="28" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#FFF8E1;strokeColor=#FFC107;strokeWidth=2;arcSize=10;" value="" vertex="1">
          <mxGeometry height="120" width="220" x="340" y="570" as="geometry" />
        </mxCell>
        <mxCell id="29" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#FFC107;strokeColor=#FF8F00;fontSize=18;fontFamily=Consolas;fontStyle=1;fontColor=#FFFFFF;" value="continue" vertex="1">
          <mxGeometry height="40" width="140" x="380" y="585" as="geometry" />
        </mxCell>
        <mxCell id="30" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=14;fontColor=#FF8F00;" value="跳过本次循环&lt;br&gt;继续下一次" vertex="1">
          <mxGeometry height="45" width="180" x="360" y="635" as="geometry" />
        </mxCell>
        <mxCell id="31" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#E8F5E9;strokeColor=#4CAF50;strokeWidth=2;arcSize=10;" value="" vertex="1">
          <mxGeometry height="120" width="220" x="590" y="570" as="geometry" />
        </mxCell>
        <mxCell id="32" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#4CAF50;strokeColor=#2E7D32;fontSize=18;fontFamily=Consolas;fontStyle=1;fontColor=#FFFFFF;" value="return" vertex="1">
          <mxGeometry height="40" width="140" x="630" y="585" as="geometry" />
        </mxCell>
        <mxCell id="33" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=14;fontColor=#2E7D32;" value="结束方法执行&lt;br&gt;返回结果" vertex="1">
          <mxGeometry height="45" width="180" x="610" y="635" as="geometry" />
        </mxCell>
        <mxCell id="34" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=32;" value="📘" vertex="1">
          <mxGeometry height="50" width="50" x="210" y="255" as="geometry" />
        </mxCell>
        <mxCell id="35" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=32;" value="🔀" vertex="1">
          <mxGeometry height="50" width="50" x="490" y="255" as="geometry" />
        </mxCell>
        <mxCell id="36" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=32;" value="🔄" vertex="1">
          <mxGeometry height="50" width="50" x="765" y="252.5" as="geometry" />
        </mxCell>
      </root>
    </mxGraphModel>
  </diagram>
</mxfile>

4.2 continue、break、return 对比

<mxfile>
  <diagram id="continue-break-return" name="continue/break/return对比">
    <mxGraphModel dx="850" dy="580" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="850" pageHeight="580">
      <root>
        <mxCell id="0" />
        <mxCell id="1" parent="0" />
        <mxCell id="2" value="" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#FAFAFA;strokeColor=#5C6BC0;strokeWidth=3;arcSize=3;" vertex="1" parent="1">
          <mxGeometry x="20" y="20" width="810" height="540" as="geometry" />
        </mxCell>
        <mxCell id="3" value="continue / break / return 对比" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=24;fontStyle=1;fontColor=#3949AB;" vertex="1" parent="1">
          <mxGeometry x="200" y="40" width="450" height="40" as="geometry" />
        </mxCell>
        <mxCell id="4" value="" style="line;strokeWidth=3;fillColor=none;align=left;verticalAlign=middle;spacingTop=-1;spacingLeft=3;spacingRight=3;rotatable=0;labelPosition=right;points=[];portConstraint=eastwest;strokeColor=#9FA8DA;" vertex="1" parent="1">
          <mxGeometry x="50" y="90" width="750" height="10" as="geometry" />
        </mxCell>
        <mxCell id="5" value="语句" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#3949AB;strokeColor=#1A237E;strokeWidth=2;fontSize=18;fontStyle=1;fontColor=#FFFFFF;" vertex="1" parent="1">
          <mxGeometry x="50" y="115" width="150" height="50" as="geometry" />
        </mxCell>
        <mxCell id="6" value="作用" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#3949AB;strokeColor=#1A237E;strokeWidth=2;fontSize=18;fontStyle=1;fontColor=#FFFFFF;" vertex="1" parent="1">
          <mxGeometry x="200" y="115" width="600" height="50" as="geometry" />
        </mxCell>
        <mxCell id="7" value="" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#E8F5E9;strokeColor=#4CAF50;strokeWidth=2;" vertex="1" parent="1">
          <mxGeometry x="50" y="165" width="150" height="120" as="geometry" />
        </mxCell>
        <mxCell id="8" value="continue" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#4CAF50;strokeColor=#2E7D32;fontSize=18;fontFamily=Consolas;fontStyle=1;fontColor=#FFFFFF;shadow=1;" vertex="1" parent="1">
          <mxGeometry x="65" y="200" width="120" height="45" as="geometry" />
        </mxCell>
        <mxCell id="9" value="" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#E8F5E9;strokeColor=#4CAF50;strokeWidth=2;" vertex="1" parent="1">
          <mxGeometry x="200" y="165" width="600" height="120" as="geometry" />
        </mxCell>
        <mxCell id="10" value="跳过当前循环的剩余代码,进入下一次循环迭代" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=16;fontColor=#2E7D32;fontStyle=1;spacingLeft=15;" vertex="1" parent="1">
          <mxGeometry x="210" y="180" width="570" height="35" as="geometry" />
        </mxCell>
        <mxCell id="11" value="⚡ 只影响最内层循环" style="text;html=1;strokeColor=none;fillColor=#C8E6C9;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=1;fontSize=14;fontColor=#1B5E20;spacingLeft=10;" vertex="1" parent="1">
          <mxGeometry x="230" y="225" width="200" height="35" as="geometry" />
        </mxCell>
        <mxCell id="12" value="" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#FFF3E0;strokeColor=#FF9800;strokeWidth=2;" vertex="1" parent="1">
          <mxGeometry x="50" y="285" width="150" height="120" as="geometry" />
        </mxCell>
        <mxCell id="13" value="break" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#FF9800;strokeColor=#E65100;fontSize=18;fontFamily=Consolas;fontStyle=1;fontColor=#FFFFFF;shadow=1;" vertex="1" parent="1">
          <mxGeometry x="65" y="320" width="120" height="45" as="geometry" />
        </mxCell>
        <mxCell id="14" value="" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#FFF3E0;strokeColor=#FF9800;strokeWidth=2;" vertex="1" parent="1">
          <mxGeometry x="200" y="285" width="600" height="120" as="geometry" />
        </mxCell>
        <mxCell id="15" value="跳出当前循环或 switch 语句" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=16;fontColor=#E65100;fontStyle=1;spacingLeft=15;" vertex="1" parent="1">
          <mxGeometry x="210" y="300" width="570" height="35" as="geometry" />
        </mxCell>
        <mxCell id="16" value="⚡ 只跳出最内层结构" style="text;html=1;strokeColor=none;fillColor=#FFE0B2;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=1;fontSize=14;fontColor=#E65100;spacingLeft=10;" vertex="1" parent="1">
          <mxGeometry x="230" y="345" width="200" height="35" as="geometry" />
        </mxCell>
        <mxCell id="17" value="" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#FFEBEE;strokeColor=#F44336;strokeWidth=2;" vertex="1" parent="1">
          <mxGeometry x="50" y="405" width="150" height="120" as="geometry" />
        </mxCell>
        <mxCell id="18" value="return" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#F44336;strokeColor=#C62828;fontSize=18;fontFamily=Consolas;fontStyle=1;fontColor=#FFFFFF;shadow=1;" vertex="1" parent="1">
          <mxGeometry x="65" y="440" width="120" height="45" as="geometry" />
        </mxCell>
        <mxCell id="19" value="" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#FFEBEE;strokeColor=#F44336;strokeWidth=2;" vertex="1" parent="1">
          <mxGeometry x="200" y="405" width="600" height="120" as="geometry" />
        </mxCell>
        <mxCell id="20" value="结束整个方法的执行" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=16;fontColor=#C62828;fontStyle=1;spacingLeft=15;" vertex="1" parent="1">
          <mxGeometry x="210" y="420" width="570" height="35" as="geometry" />
        </mxCell>
        <mxCell id="21" value="⚡ 可选地返回一个值" style="text;html=1;strokeColor=none;fillColor=#FFCDD2;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=1;fontSize=14;fontColor=#C62828;spacingLeft=10;" vertex="1" parent="1">
          <mxGeometry x="230" y="465" width="200" height="35" as="geometry" />
        </mxCell>
        <mxCell id="22" value="🔄" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=28;" vertex="1" parent="1">
          <mxGeometry x="460" y="220" width="50" height="45" as="geometry" />
        </mxCell>
        <mxCell id="23" value="🚪" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=28;" vertex="1" parent="1">
          <mxGeometry x="460" y="340" width="50" height="45" as="geometry" />
        </mxCell>
        <mxCell id="24" value="🏁" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=28;" vertex="1" parent="1">
          <mxGeometry x="460" y="460" width="50" height="45" as="geometry" />
        </mxCell>
        <mxCell id="25" value="影响范围:循环体内" style="text;html=1;strokeColor=none;fillColor=#A5D6A7;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=1;fontSize=13;fontColor=#1B5E20;fontStyle=1;" vertex="1" parent="1">
          <mxGeometry x="550" y="225" width="150" height="30" as="geometry" />
        </mxCell>
        <mxCell id="26" value="影响范围:循环/switch" style="text;html=1;strokeColor=none;fillColor=#FFCC80;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=1;fontSize=13;fontColor=#E65100;fontStyle=1;" vertex="1" parent="1">
          <mxGeometry x="550" y="345" width="160" height="30" as="geometry" />
        </mxCell>
        <mxCell id="27" value="影响范围:整个方法" style="text;html=1;strokeColor=none;fillColor=#EF9A9A;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=1;fontSize=13;fontColor=#C62828;fontStyle=1;" vertex="1" parent="1">
          <mxGeometry x="550" y="465" width="150" height="30" as="geometry" />
        </mxCell>
      </root>
    </mxGraphModel>
  </diagram>
</mxfile>

图解执行流程

<mxfile>
  <diagram id="execution-flow-diagram" name="执行流程图解">
    <mxGraphModel dx="1281" dy="581" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="1050" pageHeight="1020" math="0" shadow="0">
      <root>
        <mxCell id="0" />
        <mxCell id="1" parent="0" />
        <mxCell id="2" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#FAFAFA;strokeColor=#5C6BC0;strokeWidth=3;arcSize=2;" value="" vertex="1">
          <mxGeometry height="1070" width="1010" x="20" y="20" as="geometry" />
        </mxCell>
        <mxCell id="3" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=26;fontStyle=1;fontColor=#3949AB;" value="执行流程图解" vertex="1">
          <mxGeometry height="40" width="270" x="390" y="40" as="geometry" />
        </mxCell>
        <mxCell id="4" parent="1" style="line;strokeWidth=3;fillColor=none;align=left;verticalAlign=middle;spacingTop=-1;spacingLeft=3;spacingRight=3;rotatable=0;labelPosition=right;points=[];portConstraint=eastwest;strokeColor=#9FA8DA;" value="" vertex="1">
          <mxGeometry height="10" width="950" x="50" y="90" as="geometry" />
        </mxCell>
        <mxCell id="5" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#4CAF50;strokeColor=#2E7D32;strokeWidth=2;fontSize=20;fontFamily=Consolas;fontStyle=1;fontColor=#FFFFFF;shadow=1;" value="continue" vertex="1">
          <mxGeometry height="45" width="140" x="50" y="115" as="geometry" />
        </mxCell>
        <mxCell id="6" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#E8F5E9;strokeColor=#4CAF50;strokeWidth=2;arcSize=3;" value="" vertex="1">
          <mxGeometry height="230" width="950" x="50" y="175" as="geometry" />
        </mxCell>
        <mxCell id="7" parent="1" style="text;html=1;strokeColor=none;fillColor=#C8E6C9;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=1;fontSize=15;fontFamily=Consolas;fontColor=#1B5E20;spacingLeft=10;" value="for (int i = 0; i &lt; 5; i++) {" vertex="1">
          <mxGeometry height="35" width="280" x="70" y="195" as="geometry" />
        </mxCell>
        <mxCell id="8" parent="1" style="text;html=1;strokeColor=none;fillColor=#A5D6A7;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=1;fontSize=15;fontFamily=Consolas;fontColor=#1B5E20;spacingLeft=10;fontStyle=1;" value="if (i == 2) continue;" vertex="1">
          <mxGeometry height="35" width="230" x="100" y="240" as="geometry" />
        </mxCell>
        <mxCell id="9" parent="1" style="text;html=1;strokeColor=none;fillColor=#C8E6C9;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=1;fontSize=15;fontFamily=Consolas;fontColor=#1B5E20;spacingLeft=10;" value="System.out.println(i);" vertex="1">
          <mxGeometry height="35" width="250" x="100" y="285" as="geometry" />
        </mxCell>
        <mxCell id="10" parent="1" style="text;html=1;strokeColor=none;fillColor=#C8E6C9;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=1;fontSize=15;fontFamily=Consolas;fontColor=#1B5E20;spacingLeft=10;" value="}" vertex="1">
          <mxGeometry height="35" width="40" x="70" y="330" as="geometry" />
        </mxCell>
        <mxCell id="11" edge="1" parent="1" source="8" style="edgeStyle=orthogonalEdgeStyle;rounded=1;orthogonalLoop=1;jettySize=auto;html=1;strokeWidth=3;strokeColor=#4CAF50;endArrow=classic;endFill=1;entryX=1;entryY=0.5;entryDx=0;entryDy=0;exitX=1;exitY=0.5;exitDx=0;exitDy=0;curved=0;" target="10" value="">
          <mxGeometry relative="1" as="geometry">
            <Array as="points">
              <mxPoint x="400" y="258" />
              <mxPoint x="400" y="348" />
            </Array>
          </mxGeometry>
        </mxCell>
        <mxCell id="12" parent="1" style="text;html=1;strokeColor=none;fillColor=#FFFFFF;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=1;fontSize=14;fontColor=#2E7D32;fontStyle=1;shadow=1;" value="跳过,但继续循环" vertex="1">
          <mxGeometry height="35" width="140" x="410" y="280" as="geometry" />
        </mxCell>
        <mxCell id="13" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=24;" value="🔄" vertex="1">
          <mxGeometry height="35" width="40" x="410" y="240" as="geometry" />
        </mxCell>
        <mxCell id="14" parent="1" style="text;html=1;strokeColor=none;fillColor=#FFFFFF;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=1;fontSize=16;fontFamily=Consolas;fontColor=#2E7D32;fontStyle=1;spacingLeft=10;shadow=1;" value="输出: 0 1 3 4" vertex="1">
          <mxGeometry height="40" width="160" x="600" y="220" as="geometry" />
        </mxCell>
        <mxCell id="15" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=14;fontColor=#4CAF50;spacingLeft=5;" value="(跳过了 2)" vertex="1">
          <mxGeometry height="40" width="100" x="770" y="220" as="geometry" />
        </mxCell>
        <mxCell id="50" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#E8F5E9;strokeColor=#81C784;strokeWidth=2;strokeDasharray=3 3;" value="" vertex="1">
          <mxGeometry height="110" width="380" x="600" y="280" as="geometry" />
        </mxCell>
        <mxCell id="51" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=13;fontFamily=Consolas;fontColor=#2E7D32;spacingLeft=10;" value="i=0 → 打印0 ✓&lt;br&gt;i=1 → 打印1 ✓&lt;br&gt;i=2 → continue跳过 ✗&lt;br&gt;i=3 → 打印3 ✓&lt;br&gt;i=4 → 打印4 ✓" vertex="1">
          <mxGeometry height="100" width="350" x="615" y="285" as="geometry" />
        </mxCell>
        <mxCell id="16" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#FF9800;strokeColor=#E65100;strokeWidth=2;fontSize=20;fontFamily=Consolas;fontStyle=1;fontColor=#FFFFFF;shadow=1;" value="break" vertex="1">
          <mxGeometry height="45" width="140" x="50" y="420" as="geometry" />
        </mxCell>
        <mxCell id="17" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#FFF3E0;strokeColor=#FF9800;strokeWidth=2;arcSize=3;" value="" vertex="1">
          <mxGeometry height="230" width="950" x="50" y="480" as="geometry" />
        </mxCell>
        <mxCell id="18" parent="1" style="text;html=1;strokeColor=none;fillColor=#FFE0B2;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=1;fontSize=15;fontFamily=Consolas;fontColor=#E65100;spacingLeft=10;" value="for (int i = 0; i &lt; 5; i++) {" vertex="1">
          <mxGeometry height="35" width="280" x="70" y="500" as="geometry" />
        </mxCell>
        <mxCell id="19" parent="1" style="text;html=1;strokeColor=none;fillColor=#FFCC80;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=1;fontSize=15;fontFamily=Consolas;fontColor=#E65100;spacingLeft=10;fontStyle=1;" value="if (i == 2) break;" vertex="1">
          <mxGeometry height="35" width="210" x="100" y="545" as="geometry" />
        </mxCell>
        <mxCell id="20" parent="1" style="text;html=1;strokeColor=none;fillColor=#FFE0B2;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=1;fontSize=15;fontFamily=Consolas;fontColor=#E65100;spacingLeft=10;" value="System.out.println(i);" vertex="1">
          <mxGeometry height="35" width="250" x="100" y="590" as="geometry" />
        </mxCell>
        <mxCell id="21" parent="1" style="text;html=1;strokeColor=none;fillColor=#FFE0B2;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=1;fontSize=15;fontFamily=Consolas;fontColor=#E65100;spacingLeft=10;" value="}" vertex="1">
          <mxGeometry height="35" width="40" x="70" y="635" as="geometry" />
        </mxCell>
        <mxCell id="22" parent="1" style="text;html=1;strokeColor=none;fillColor=#FFF8E1;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=1;fontSize=14;fontFamily=Consolas;fontColor=#FF8F00;spacingLeft=10;fontStyle=2;" value="// 继续执行这里" vertex="1">
          <mxGeometry height="30" width="180" x="70" y="675" as="geometry" />
        </mxCell>
        <mxCell id="23" edge="1" parent="1" source="19" style="edgeStyle=orthogonalEdgeStyle;rounded=1;orthogonalLoop=1;jettySize=auto;html=1;strokeWidth=3;strokeColor=#FF9800;endArrow=classic;endFill=1;exitX=1;exitY=0.5;exitDx=0;exitDy=0;entryX=1;entryY=0.5;entryDx=0;entryDy=0;curved=0;" target="22" value="">
          <mxGeometry relative="1" as="geometry">
            <Array as="points">
              <mxPoint x="380" y="563" />
              <mxPoint x="380" y="690" />
            </Array>
          </mxGeometry>
        </mxCell>
        <mxCell id="24" parent="1" style="text;html=1;strokeColor=none;fillColor=#FFFFFF;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=1;fontSize=14;fontColor=#E65100;fontStyle=1;shadow=1;" value="跳出整个循环" vertex="1">
          <mxGeometry height="35" width="120" x="390" y="605" as="geometry" />
        </mxCell>
        <mxCell id="25" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=24;" value="🚪" vertex="1">
          <mxGeometry height="35" width="40" x="340" y="545" as="geometry" />
        </mxCell>
        <mxCell id="26" parent="1" style="text;html=1;strokeColor=none;fillColor=#FFFFFF;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=1;fontSize=16;fontFamily=Consolas;fontColor=#E65100;fontStyle=1;spacingLeft=10;shadow=1;" value="输出: 0 1" vertex="1">
          <mxGeometry height="40" width="120" x="600" y="520" as="geometry" />
        </mxCell>
        <mxCell id="27" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=14;fontColor=#FF9800;spacingLeft=5;" value="(遇到 2 就退出)" vertex="1">
          <mxGeometry height="40" width="130" x="730" y="520" as="geometry" />
        </mxCell>
        <mxCell id="52" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#FFF3E0;strokeColor=#FFCC80;strokeWidth=2;strokeDasharray=3 3;" value="" vertex="1">
          <mxGeometry height="110" width="380" x="600" y="580" as="geometry" />
        </mxCell>
        <mxCell id="53" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=13;fontFamily=Consolas;fontColor=#E65100;spacingLeft=10;" value="i=0 → 打印0 ✓&lt;br&gt;i=1 → 打印1 ✓&lt;br&gt;i=2 → break退出循环 ⛔&lt;br&gt;i=3 → 不执行&lt;br&gt;i=4 → 不执行" vertex="1">
          <mxGeometry height="100" width="350" x="615" y="585" as="geometry" />
        </mxCell>
        <mxCell id="28" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#F44336;strokeColor=#C62828;strokeWidth=2;fontSize=20;fontFamily=Consolas;fontStyle=1;fontColor=#FFFFFF;shadow=1;" value="return" vertex="1">
          <mxGeometry height="45" width="140" x="50" y="725" as="geometry" />
        </mxCell>
        <mxCell id="29" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#FFEBEE;strokeColor=#F44336;strokeWidth=2;arcSize=3;" value="" vertex="1">
          <mxGeometry height="245" width="950" x="50" y="785" as="geometry" />
        </mxCell>
        <mxCell id="30" parent="1" style="text;html=1;strokeColor=none;fillColor=#FFCDD2;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=1;fontSize=15;fontFamily=Consolas;fontColor=#C62828;spacingLeft=10;" value="public void method() {" vertex="1">
          <mxGeometry height="30" width="250" x="70" y="800" as="geometry" />
        </mxCell>
        <mxCell id="31" parent="1" style="text;html=1;strokeColor=none;fillColor=#FFCDD2;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=1;fontSize=14;fontFamily=Consolas;fontColor=#C62828;spacingLeft=10;" value="for (int i = 0; i &lt; 5; i++) {" vertex="1">
          <mxGeometry height="28" width="260" x="100" y="835" as="geometry" />
        </mxCell>
        <mxCell id="32" parent="1" style="text;html=1;strokeColor=none;fillColor=#EF9A9A;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=1;fontSize=14;fontFamily=Consolas;fontColor=#C62828;spacingLeft=10;fontStyle=1;" value="if (i == 2) return;" vertex="1">
          <mxGeometry height="28" width="200" x="130" y="868" as="geometry" />
        </mxCell>
        <mxCell id="33" parent="1" style="text;html=1;strokeColor=none;fillColor=#FFCDD2;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=1;fontSize=14;fontFamily=Consolas;fontColor=#C62828;spacingLeft=10;" value="System.out.println(i);" vertex="1">
          <mxGeometry height="28" width="230" x="130" y="901" as="geometry" />
        </mxCell>
        <mxCell id="34" parent="1" style="text;html=1;strokeColor=none;fillColor=#FFCDD2;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=1;fontSize=14;fontFamily=Consolas;fontColor=#C62828;spacingLeft=10;" value="}" vertex="1">
          <mxGeometry height="28" width="30" x="100" y="934" as="geometry" />
        </mxCell>
        <mxCell id="35" parent="1" style="text;html=1;strokeColor=none;fillColor=#FFCDD2;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=1;fontSize=14;fontFamily=Consolas;fontColor=#B71C1C;spacingLeft=10;opacity=50;" value="System.out.println(&quot;循环结束&quot;);" vertex="1">
          <mxGeometry height="28" width="290" x="100" y="964" as="geometry" />
        </mxCell>
        <mxCell id="36" parent="1" style="text;html=1;strokeColor=none;fillColor=#FFCDD2;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=1;fontSize=15;fontFamily=Consolas;fontColor=#C62828;spacingLeft=10;" value="}" vertex="1">
          <mxGeometry height="30" width="30" x="70" y="990" as="geometry" />
        </mxCell>
        <mxCell id="37" parent="1" style="text;html=1;strokeColor=none;fillColor=#FFEBEE;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=1;fontSize=14;fontFamily=Consolas;fontColor=#D32F2F;spacingLeft=10;fontStyle=2;" value="// 方法结束" vertex="1">
          <mxGeometry height="25" width="140" x="120" y="995" as="geometry" />
        </mxCell>
        <mxCell id="38" edge="1" parent="1" source="32" style="edgeStyle=orthogonalEdgeStyle;rounded=1;orthogonalLoop=1;jettySize=auto;html=1;strokeWidth=3;strokeColor=#F44336;endArrow=classic;endFill=1;exitX=1;exitY=0.5;exitDx=0;exitDy=0;curved=0;" target="37" value="">
          <mxGeometry relative="1" as="geometry">
            <Array as="points">
              <mxPoint x="400" y="882" />
              <mxPoint x="400" y="1008" />
            </Array>
          </mxGeometry>
        </mxCell>
        <mxCell id="39" parent="1" style="text;html=1;strokeColor=none;fillColor=#FFFFFF;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=1;fontSize=14;fontColor=#C62828;fontStyle=1;shadow=1;" value="结束整个方法" vertex="1">
          <mxGeometry height="35" width="120" x="410" y="905" as="geometry" />
        </mxCell>
        <mxCell id="40" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=24;" value="🏁" vertex="1">
          <mxGeometry height="30" width="40" x="355" y="865" as="geometry" />
        </mxCell>
        <mxCell id="41" parent="1" style="text;html=1;strokeColor=none;fillColor=#EF5350;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=1;fontSize=12;fontColor=#FFFFFF;fontStyle=1;" value="不会执行" vertex="1">
          <mxGeometry height="25" width="70" x="410" y="974" as="geometry" />
        </mxCell>
        <mxCell id="42" parent="1" style="text;html=1;strokeColor=none;fillColor=#FFFFFF;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=1;fontSize=16;fontFamily=Consolas;fontColor=#C62828;fontStyle=1;spacingLeft=10;shadow=1;" value="输出: 0 1" vertex="1">
          <mxGeometry height="40" width="120" x="600" y="810" as="geometry" />
        </mxCell>
        <mxCell id="43" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=14;fontColor=#F44336;spacingLeft=5;" value="(方法提前结束)" vertex="1">
          <mxGeometry height="40" width="130" x="730" y="810" as="geometry" />
        </mxCell>
        <mxCell id="54" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#FFEBEE;strokeColor=#EF9A9A;strokeWidth=2;strokeDasharray=3 3;" value="" vertex="1">
          <mxGeometry height="110" width="380" x="600" y="865" as="geometry" />
        </mxCell>
        <mxCell id="55" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=13;fontFamily=Consolas;fontColor=#C62828;spacingLeft=10;" value="i=0 → 打印0 ✓&lt;br&gt;i=1 → 打印1 ✓&lt;br&gt;i=2 → return结束方法 🛑&lt;br&gt;&quot;循环结束&quot; → 不执行&lt;br&gt;方法直接返回" vertex="1">
          <mxGeometry height="100" width="350" x="615" y="870" as="geometry" />
        </mxCell>
      </root>
    </mxGraphModel>
  </diagram>
</mxfile>

代码示例

public class FlowControlDemo {

    public static void main(String[] args) {
        // ═══════════════════════════════════════════════════════════════
        // continue 示例:跳过偶数
        // ═══════════════════════════════════════════════════════════════
        System.out.println("=== continue 示例 ===");
        for (int i = 0; i < 10; i++) {
            if (i % 2 == 0) {
                continue;  // 跳过偶数
            }
            System.out.print(i + " ");  // 输出: 1 3 5 7 9
        }
        System.out.println();

        // ═══════════════════════════════════════════════════════════════
        // break 示例:找到目标后退出
        // ═══════════════════════════════════════════════════════════════
        System.out.println("=== break 示例 ===");
        int[] nums = {1, 3, 5, 7, 9, 2, 4};
        int target = 7;
        int index = -1;

        for (int i = 0; i < nums.length; i++) {
            if (nums[i] == target) {
                index = i;
                break;  // 找到后立即退出,不继续遍历
            }
        }
        System.out.println("找到 " + target + " 在索引 " + index);

        // ═══════════════════════════════════════════════════════════════
        // return 示例:条件满足时提前返回
        // ═══════════════════════════════════════════════════════════════
        System.out.println("=== return 示例 ===");
        printPositive(-5);  // 输出: 数字必须为正数
        printPositive(10);  // 输出: 正数: 10
    }

    public static void printPositive(int num) {
        if (num <= 0) {
            System.out.println("数字必须为正数");
            return;  // 提前返回,后面的代码不执行
        }
        System.out.println("正数: " + num);
    }
}

4.3 带标签的 break 和 continue

// ═══════════════════════════════════════════════════════════════════════
// 问题:如何在嵌套循环中跳出外层循环?
// ═══════════════════════════════════════════════════════════════════════

// ❌ 普通 break 只能跳出内层循环
for (int i = 0; i < 3; i++) {
    for (int j = 0; j < 3; j++) {
        if (i == 1 && j == 1) {
            break;  // 只跳出内层 for
        }
        System.out.println("i=" + i + ", j=" + j);
    }
}
// 外层循环还会继续执行 i=2 的情况

// ═══════════════════════════════════════════════════════════════════════
// ✅ 使用带标签的 break
// ═══════════════════════════════════════════════════════════════════════

outer:  // 标签
for (int i = 0; i < 3; i++) {
    for (int j = 0; j < 3; j++) {
        if (i == 1 && j == 1) {
            break outer;  // 跳出外层循环
        }
        System.out.println("i=" + i + ", j=" + j);
    }
}
// 输出:
// i=0, j=0
// i=0, j=1
// i=0, j=2
// i=1, j=0
// (遇到 i=1, j=1 时跳出外层循环)

// ═══════════════════════════════════════════════════════════════════════
// 带标签的 continue
// ═══════════════════════════════════════════════════════════════════════

outer:
for (int i = 0; i < 3; i++) {
    for (int j = 0; j < 3; j++) {
        if (j == 1) {
            continue outer;  // 跳到外层循环的下一次迭代
        }
        System.out.println("i=" + i + ", j=" + j);
    }
}
// 输出:
// i=0, j=0
// i=1, j=0
// i=2, j=0
// (每次 j=1 时跳过内层剩余,进入外层下一次)
<mxfile>
  <diagram id="break-label-diagram" name="带标签的break图解">
    <mxGraphModel dx="1068" dy="484" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="900" pageHeight="600" math="0" shadow="0">
      <root>
        <mxCell id="0" />
        <mxCell id="1" parent="0" />
        <mxCell id="2" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=18;fontStyle=1;fontColor=#333333;" value="带标签的 break 图解" vertex="1">
          <mxGeometry height="40" width="300" x="300" y="30" as="geometry" />
        </mxCell>
        <mxCell id="3" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;fontSize=13;fontStyle=1;fontColor=#6366F1;" value="outer:" vertex="1">
          <mxGeometry height="24" width="60" x="60" y="70" as="geometry" />
        </mxCell>
        <mxCell id="4" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#EEF2FF;strokeColor=#6366F1;strokeWidth=2;" value="" vertex="1">
          <mxGeometry height="280" width="680" x="60" y="94" as="geometry" />
        </mxCell>
        <mxCell id="5" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;fontSize=12;fontFamily=Courier New;fontColor=#1E1E1E;" value="for (int i = 0; i &lt; 3; i++) {" vertex="1">
          <mxGeometry height="24" width="220" x="80" y="104" as="geometry" />
        </mxCell>
        <mxCell id="6" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#FEF3C7;strokeColor=#F59E0B;strokeWidth=2;" value="" vertex="1">
          <mxGeometry height="172" width="560" x="100" y="138" as="geometry" />
        </mxCell>
        <mxCell id="7" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;fontSize=12;fontFamily=Courier New;fontColor=#1E1E1E;" value="for (int j = 0; j &lt; 3; j++) {" vertex="1">
          <mxGeometry height="24" width="220" x="120" y="148" as="geometry" />
        </mxCell>
        <mxCell id="8" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;fontSize=12;fontFamily=Courier New;fontColor=#1E1E1E;" value="if (i == 1 &amp;&amp; j == 1) {" vertex="1">
          <mxGeometry height="24" width="200" x="140" y="180" as="geometry" />
        </mxCell>
        <mxCell id="9" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#FEE2E2;strokeColor=#EF4444;strokeWidth=2;fontSize=12;fontFamily=Courier New;fontStyle=1;fontColor=#DC2626;" value="break outer;" vertex="1">
          <mxGeometry height="32" width="140" x="160" y="212" as="geometry" />
        </mxCell>
        <mxCell id="10" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;fontSize=12;fontFamily=Courier New;fontColor=#1E1E1E;" value="}" vertex="1">
          <mxGeometry height="24" width="20" x="140" y="252" as="geometry" />
        </mxCell>
        <mxCell id="11" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;fontSize=12;fontFamily=Courier New;fontColor=#6B7280;" value="// 其他代码..." vertex="1">
          <mxGeometry height="24" width="140" x="140" y="280" as="geometry" />
        </mxCell>
        <mxCell id="12" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;fontSize=12;fontFamily=Courier New;fontColor=#1E1E1E;" value="}" vertex="1">
          <mxGeometry height="24" width="20" x="120" y="310" as="geometry" />
        </mxCell>
        <mxCell id="13" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;fontSize=12;fontFamily=Courier New;fontColor=#1E1E1E;" value="}" vertex="1">
          <mxGeometry height="24" width="20" x="80" y="350" as="geometry" />
        </mxCell>
        <mxCell id="14" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#D1FAE5;strokeColor=#10B981;strokeWidth=2;fontSize=12;fontFamily=Courier New;fontColor=#047857;" value="// 代码继续执行" vertex="1">
          <mxGeometry height="36" width="160" x="70" y="400" as="geometry" />
        </mxCell>
        <mxCell id="15" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;fontSize=11;fontColor=#6366F1;fontStyle=2;" value="outer 标签指向这里" vertex="1">
          <mxGeometry height="24" width="130" x="490" y="104" as="geometry" />
        </mxCell>
        <mxCell id="16" edge="1" parent="1" style="endArrow=classic;html=1;strokeColor=#6366F1;strokeWidth=2;entryX=1;entryY=0.5;entryDx=0;entryDy=0;" value="">
          <mxGeometry relative="1" as="geometry">
            <mxPoint x="490" y="114" as="sourcePoint" />
            <mxPoint x="300" y="114" as="targetPoint" />
          </mxGeometry>
        </mxCell>
        <mxCell id="17" edge="1" parent="1" style="edgeStyle=orthogonalEdgeStyle;rounded=1;orthogonalLoop=1;jettySize=auto;html=1;strokeColor=#EF4444;strokeWidth=3;endArrow=blockThin;endFill=1;dashed=1;dashPattern=8 4;entryX=1;entryY=0.5;entryDx=0;entryDy=0;" target="14" value="">
          <mxGeometry relative="1" as="geometry">
            <Array as="points">
              <mxPoint x="780" y="228" />
              <mxPoint x="780" y="418" />
            </Array>
            <mxPoint x="300" y="228" as="sourcePoint" />
            <mxPoint x="140" y="418" as="targetPoint" />
          </mxGeometry>
        </mxCell>
        <mxCell id="18" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=11;fontColor=#EF4444;fontStyle=3;" value="跳出所有循环" vertex="1">
          <mxGeometry height="24" width="90" x="770" y="300" as="geometry" />
        </mxCell>
        <mxCell id="19" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;fontSize=10;fontColor=#6366F1;fontStyle=1;labelBackgroundColor=#EEF2FF;labelBorderColor=none;" value="外层循环 (i)" vertex="1">
          <mxGeometry height="20" width="80" x="650" y="94" as="geometry" />
        </mxCell>
        <mxCell id="20" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;fontSize=10;fontColor=#F59E0B;fontStyle=1;labelBackgroundColor=#FEF3C7;" value="内层循环 (j)" vertex="1">
          <mxGeometry height="20" width="80" x="570" y="138" as="geometry" />
        </mxCell>
      </root>
    </mxGraphModel>
  </diagram>
</mxfile>

4.4 实际应用场景

// ═══════════════════════════════════════════════════════════════════════
// 场景 1:搜索二维数组
// ═══════════════════════════════════════════════════════════════════════
public static int[] findElement(int[][] matrix, int target) {
    for (int i = 0; i < matrix.length; i++) {
        for (int j = 0; j < matrix[i].length; j++) {
            if (matrix[i][j] == target) {
                return new int[]{i, j};  // return 最简洁
            }
        }
    }
    return null;
}

// ═══════════════════════════════════════════════════════════════════════
// 场景 2:参数校验(卫语句模式)
// ═══════════════════════════════════════════════════════════════════════
public void processOrder(Order order) {
    // 卫语句:尽早 return,减少嵌套
    if (order == null) {
        log.warn("订单为空");
        return;
    }
    if (order.getItems().isEmpty()) {
        log.warn("订单项为空");
        return;
    }
    if (order.getStatus() != OrderStatus.PENDING) {
        log.warn("订单状态不是待处理");
        return;
    }

    // 正常业务逻辑(不需要嵌套在多层 if 中)
    doProcess(order);
}

// ═══════════════════════════════════════════════════════════════════════
// 场景 3:过滤处理(continue 跳过不符合条件的项)
// ═══════════════════════════════════════════════════════════════════════
public void processValidUsers(List<User> users) {
    for (User user : users) {
        // 跳过无效用户
        if (user == null) continue;
        if (!user.isActive()) continue;
        if (user.getAge() < 18) continue;

        // 处理有效用户
        sendNotification(user);
    }
}

// ═══════════════════════════════════════════════════════════════════════
// 场景 4:限制循环次数或超时退出(break)
// ═══════════════════════════════════════════════════════════════════════
public Data pollWithTimeout(Queue<Data> queue, long timeoutMs) {
    long startTime = System.currentTimeMillis();

    while (true) {
        Data data = queue.poll();
        if (data != null) {
            return data;
        }

        // 超时退出
        if (System.currentTimeMillis() - startTime > timeoutMs) {
            break;
        }

        Thread.sleep(100);
    }

    return null;  // 超时返回 null
}

4.5 switch 语句增强(JDK 12+)

// ═══════════════════════════════════════════════════════════════════════
// 传统 switch(需要 break)
// ═══════════════════════════════════════════════════════════════════════
int dayOfWeek = 3;
String dayType;

switch (dayOfWeek) {
    case 1:
    case 2:
    case 3:
    case 4:
    case 5:
        dayType = "工作日";
        break;  // 必须 break,否则会穿透
    case 6:
    case 7:
        dayType = "周末";
        break;
    default:
        dayType = "未知";
        break;
}

// ═══════════════════════════════════════════════════════════════════════
// 增强 switch(JDK 12+)- 箭头语法,无需 break
// ═══════════════════════════════════════════════════════════════════════
String dayType = switch (dayOfWeek) {
    case 1, 2, 3, 4, 5 -> "工作日";  // 多个值用逗号分隔
    case 6, 7 -> "周末";
    default -> "未知";
};

// ═══════════════════════════════════════════════════════════════════════
// switch 表达式(JDK 14+)- 使用 yield 返回值
// ═══════════════════════════════════════════════════════════════════════
String description = switch (dayOfWeek) {
    case 1 -> "Monday";
    case 2 -> "Tuesday";
    default -> {
        // 需要多行代码时用代码块
        String result = "Day " + dayOfWeek;
        yield result;  // 使用 yield 返回值
    }
};

// ═══════════════════════════════════════════════════════════════════════
// 模式匹配 switch(JDK 21+)
// ═══════════════════════════════════════════════════════════════════════
Object obj = "Hello";

String result = switch (obj) {
    case Integer i -> "整数: " + i;
    case String s -> "字符串: " + s;
    case Long l -> "长整数: " + l;
    case null -> "空值";
    default -> "其他类型";
};

五、总结

 <mxfile>
  <diagram id="java-syntax-summary" name="基本语法要点">
    <mxGraphModel dx="900" dy="700" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="900" pageHeight="700">
      <root>
        <mxCell id="0" />
        <mxCell id="1" parent="0" />
        <mxCell id="2" value="基本语法要点 - 核心总结" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=22;fontStyle=1;fontColor=#1E293B;" vertex="1" parent="1">
          <mxGeometry x="250" y="20" width="400" height="40" as="geometry" />
        </mxCell>
        <mxCell id="3" value="" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#EFF6FF;strokeColor=#3B82F6;strokeWidth=2;" vertex="1" parent="1">
          <mxGeometry x="40" y="80" width="400" height="140" as="geometry" />
        </mxCell>
        <mxCell id="4" value="📝 注释" style="text;html=1;strokeColor=none;fillColor=#3B82F6;align=left;verticalAlign=middle;fontSize=14;fontStyle=1;fontColor=#FFFFFF;rounded=1;spacingLeft=8;" vertex="1" parent="1">
          <mxGeometry x="40" y="80" width="100" height="28" as="geometry" />
        </mxCell>
        <mxCell id="5" value="• 单行 //&amp;nbsp; 多行 /* */&amp;nbsp; 文档 /** */" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;fontSize=12;fontColor=#334155;spacingLeft=4;" vertex="1" parent="1">
          <mxGeometry x="50" y="115" width="380" height="24" as="geometry" />
        </mxCell>
        <mxCell id="6" value="• 编译时移除,好代码自解释" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;fontSize=12;fontColor=#334155;spacingLeft=4;" vertex="1" parent="1">
          <mxGeometry x="50" y="142" width="380" height="24" as="geometry" />
        </mxCell>
        <mxCell id="7" value="• 注释解释&quot;为什么&quot;,而非&quot;是什么&quot;" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;fontSize=12;fontColor=#334155;spacingLeft=4;" vertex="1" parent="1">
          <mxGeometry x="50" y="169" width="380" height="24" as="geometry" />
        </mxCell>
        <mxCell id="8" value="" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#F0FDF4;strokeColor=#22C55E;strokeWidth=2;" vertex="1" parent="1">
          <mxGeometry x="460" y="80" width="400" height="140" as="geometry" />
        </mxCell>
        <mxCell id="9" value="🏷️ 标识符与关键字" style="text;html=1;strokeColor=none;fillColor=#22C55E;align=left;verticalAlign=middle;fontSize=14;fontStyle=1;fontColor=#FFFFFF;rounded=1;spacingLeft=8;" vertex="1" parent="1">
          <mxGeometry x="460" y="80" width="150" height="28" as="geometry" />
        </mxCell>
        <mxCell id="10" value="• 标识符:程序中的命名" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;fontSize=12;fontColor=#334155;spacingLeft=4;" vertex="1" parent="1">
          <mxGeometry x="470" y="115" width="380" height="24" as="geometry" />
        </mxCell>
        <mxCell id="11" value="• 关键字:50个保留标识符,不能用于命名" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;fontSize=12;fontColor=#334155;spacingLeft=4;" vertex="1" parent="1">
          <mxGeometry x="470" y="142" width="380" height="24" as="geometry" />
        </mxCell>
        <mxCell id="12" value="• 命名规范:类大驼峰、变量小驼峰、常量全大写" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;fontSize=12;fontColor=#334155;spacingLeft=4;" vertex="1" parent="1">
          <mxGeometry x="470" y="169" width="380" height="24" as="geometry" />
        </mxCell>
        <mxCell id="13" value="" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#FEF3C7;strokeColor=#F59E0B;strokeWidth=2;" vertex="1" parent="1">
          <mxGeometry x="40" y="240" width="400" height="120" as="geometry" />
        </mxCell>
        <mxCell id="14" value="➕ 自增自减" style="text;html=1;strokeColor=none;fillColor=#F59E0B;align=left;verticalAlign=middle;fontSize=14;fontStyle=1;fontColor=#FFFFFF;rounded=1;spacingLeft=8;" vertex="1" parent="1">
          <mxGeometry x="40" y="240" width="110" height="28" as="geometry" />
        </mxCell>
        <mxCell id="15" value="• ++x 先加后用,x++ 先用后加" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;fontSize=12;fontColor=#334155;spacingLeft=4;" vertex="1" parent="1">
          <mxGeometry x="50" y="278" width="380" height="24" as="geometry" />
        </mxCell>
        <mxCell id="16" value="• i = i++ 结果是原值(字节码层面理解)" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;fontSize=12;fontColor=#334155;spacingLeft=4;" vertex="1" parent="1">
          <mxGeometry x="50" y="308" width="380" height="24" as="geometry" />
        </mxCell>
        <mxCell id="17" value="" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#FDF2F8;strokeColor=#EC4899;strokeWidth=2;" vertex="1" parent="1">
          <mxGeometry x="460" y="240" width="400" height="120" as="geometry" />
        </mxCell>
        <mxCell id="18" value="↔️ 移位运算" style="text;html=1;strokeColor=none;fillColor=#EC4899;align=left;verticalAlign=middle;fontSize=14;fontStyle=1;fontColor=#FFFFFF;rounded=1;spacingLeft=8;" vertex="1" parent="1">
          <mxGeometry x="460" y="240" width="110" height="28" as="geometry" />
        </mxCell>
        <mxCell id="19" value="• &lt;&lt; 左移(×2ⁿ)  &gt;&gt; 带符号右移  &gt;&gt;&gt; 无符号右移" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;fontSize=12;fontColor=#334155;spacingLeft=4;" vertex="1" parent="1">
          <mxGeometry x="470" y="275" width="380" height="24" as="geometry" />
        </mxCell>
        <mxCell id="20" value="• 常用于哈希计算、权限控制、性能优化" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;fontSize=12;fontColor=#334155;spacingLeft=4;" vertex="1" parent="1">
          <mxGeometry x="470" y="302" width="380" height="24" as="geometry" />
        </mxCell>
        <mxCell id="21" value="• 移位数会取模:int 取模 32,long 取模 64" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;fontSize=12;fontColor=#334155;spacingLeft=4;" vertex="1" parent="1">
          <mxGeometry x="470" y="329" width="380" height="24" as="geometry" />
        </mxCell>
        <mxCell id="22" value="" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#EDE9FE;strokeColor=#8B5CF6;strokeWidth=2;" vertex="1" parent="1">
          <mxGeometry x="40" y="380" width="820" height="160" as="geometry" />
        </mxCell>
        <mxCell id="23" value="🔄 流程控制" style="text;html=1;strokeColor=none;fillColor=#8B5CF6;align=left;verticalAlign=middle;fontSize=14;fontStyle=1;fontColor=#FFFFFF;rounded=1;spacingLeft=8;" vertex="1" parent="1">
          <mxGeometry x="40" y="380" width="110" height="28" as="geometry" />
        </mxCell>
        <mxCell id="24" value="continue" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#C4B5FD;strokeColor=#7C3AED;strokeWidth=1;fontSize=12;fontStyle=1;fontColor=#5B21B6;" vertex="1" parent="1">
          <mxGeometry x="60" y="420" width="90" height="32" as="geometry" />
        </mxCell>
        <mxCell id="25" value="跳过本次循环" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;fontSize=11;fontColor=#6B7280;" vertex="1" parent="1">
          <mxGeometry x="160" y="420" width="100" height="32" as="geometry" />
        </mxCell>
        <mxCell id="26" value="break" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#C4B5FD;strokeColor=#7C3AED;strokeWidth=1;fontSize=12;fontStyle=1;fontColor=#5B21B6;" vertex="1" parent="1">
          <mxGeometry x="270" y="420" width="90" height="32" as="geometry" />
        </mxCell>
        <mxCell id="27" value="跳出循环/switch" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;fontSize=11;fontColor=#6B7280;" vertex="1" parent="1">
          <mxGeometry x="370" y="420" width="110" height="32" as="geometry" />
        </mxCell>
        <mxCell id="28" value="return" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#C4B5FD;strokeColor=#7C3AED;strokeWidth=1;fontSize=12;fontStyle=1;fontColor=#5B21B6;" vertex="1" parent="1">
          <mxGeometry x="490" y="420" width="90" height="32" as="geometry" />
        </mxCell>
        <mxCell id="29" value="结束方法" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;fontSize=11;fontColor=#6B7280;" vertex="1" parent="1">
          <mxGeometry x="590" y="420" width="80" height="32" as="geometry" />
        </mxCell>
        <mxCell id="30" value="" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#DDD6FE;strokeColor=#7C3AED;strokeWidth=1;dashed=1;" vertex="1" parent="1">
          <mxGeometry x="60" y="470" width="780" height="55" as="geometry" />
        </mxCell>
        <mxCell id="31" value="💡 带标签的 break/continue 可跳出多层循环" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;fontSize=12;fontStyle=1;fontColor=#5B21B6;spacingLeft=8;" vertex="1" parent="1">
          <mxGeometry x="70" y="480" width="320" height="24" as="geometry" />
        </mxCell>
        <mxCell id="32" value="outer: for(...) { for(...) { break outer; } }" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;fontSize=11;fontFamily=Courier New;fontColor=#6B7280;spacingLeft=8;" vertex="1" parent="1">
          <mxGeometry x="400" y="480" width="420" height="24" as="geometry" />
        </mxCell>
        <mxCell id="33" value="" style="shape=curlyBracket;whiteSpace=wrap;html=1;rounded=1;flipH=1;labelPosition=right;verticalLabelPosition=middle;align=left;verticalAlign=middle;strokeColor=#6366F1;strokeWidth=2;size=0.5;" vertex="1" parent="1">
          <mxGeometry x="680" y="420" width="20" height="32" as="geometry" />
        </mxCell>
        <mxCell id="34" value="跳转语句" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;fontSize=11;fontColor=#6366F1;fontStyle=2;" vertex="1" parent="1">
          <mxGeometry x="705" y="420" width="70" height="32" as="geometry" />
        </mxCell>
      </root>
    </mxGraphModel>
  </diagram>
</mxfile>