集册 Java实例教程 前缀增量和后缀增量运算符。

前缀增量和后缀增量运算符。

欢马劈雪     最近更新时间:2020-01-02 10:19:05

459
提示:您可在线编辑运行本教程的实例 - 运行实例,去试试!
前缀增量和后缀增量运算符。

public class Main /*from N o w J a v a . c o m*/

{

   public static void main(String[] args)

   {   

      // demonstrate postfix increment operator

      int c = 5; 

      System.out.printf("c before postincrement: %d%n", c); // prints 5

      System.out.printf("    postincrementing c: %d%n", c++); // prints 5

      System.out.printf(" c after postincrement: %d%n", c); // prints 6


      System.out.println(); // skip a line


      // demonstrate prefix increment operator

      c = 5; 

      System.out.printf(" c before preincrement: %d%n", c); // prints 5

      System.out.printf(
展开阅读全文