The following code will not compile n i'm a little stuck as to why -

public class Question8{

    static final int ROW_SIZE = 10;
    static final int COL_SIZE;

    public static void main(String[] args){
        COL_SIZE = 10;
        ROW_SIZE = ROW_SIZE + 10;
    }
}

I'm not sure. I was able to compile without any errors.

static final int ROW_SIZE = 10;
static final int COL_SIZE;

You are declaring ROW_SIZE AND COL_SIZE as final ....
when a variable is declared as final ... its value cant be changed at any stage of the program. And you are changing the values of both .. so it wont compile.

yeah . . .

what nanosani said. When you declare a variable as a final, that variable cannot be changed - ever (well until the garbage collector comes to get it).

You must give a value to a final variable when you declare it. Otherwise, you cannot re-assign it later.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.