Re: ";" after if statement??



On 29-5-2005 20:00, JS wrote:
What does it mean when a ";" is inserted after an if statement?

if (x == 2){
    System.out.println("x = 2");
};


It's a so-called empty statement. It does nothing.

However it can become unreachable (causing a compilation error), like in the following example:

    public static int abs(int i) {
        if (i<0) {
            return -i;
        } else {
            return i;
        }
        ; // unreachable
    }

--
Regards,

Roland de Ruiter
  ___      ___
 /__/ w_/ /__/
/  \ /_/ /  \
.


Quantcast