Semicolon at end of 'if' statement

前端 未结 18 1621
没有蜡笔的小新
没有蜡笔的小新 2020-11-22 01:01

Today, after half an hour of searching for a bug, I discovered that it is possible to put a semicolon after an if statement instead of code, like this:

if(a          


        
18条回答
  •  迷失自我
    2020-11-22 01:33

    look this:

    int a,b,c = 0;
    if(a == b){
       c =1;
    } 
    System.out.print(c);//1
    

    so, you can write like this:

    if (a == b)c=1;
    

    but,if this code is this:

    int a,b,c=0;
    if (a != b){
    }
    if (a == b ){
      c =1;
    }
    

    you can write like this:

    if(a != b);
    if(a == b )c=1;
    

    so,you will know if(a != b); do noting

提交回复
热议问题