/java/

You have to know that.

2015-04-01 21:29:05

package pl.btbw;

public class Test {

    int i;

    public int getI() {
        return i;
    }

    public int getJ() {
        int j;
        return j;
    }
}

Do you know where is a bug ?

  • Local Variables have to be initialized by programer

  • Instance Variables will be initialized by java

Correct version

package pl.btbw;

public class Test {

    int i;

    public int getI() {
        return i;
    }

    public int getJ() {
        int j = 0;
        return j;
    }
}