Any chance of a little help?

Please support our Java advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Aug 2004
Posts: 1
Reputation: steventhms is an unknown quantity at this point 
Solved Threads: 0
steventhms steventhms is offline Offline
Newbie Poster

Any chance of a little help?

 
1
  #1
Aug 10th, 2004
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;
}
}
Reply With Quote Quick reply to this message  
Join Date: Aug 2004
Posts: 4
Reputation: scordle725 is an unknown quantity at this point 
Solved Threads: 0
scordle725 scordle725 is offline Offline
Newbie Poster

Re: Any chance of a little help?

 
1
  #2
Aug 10th, 2004
I'm not sure. I was able to compile without any errors.
Reply With Quote Quick reply to this message  
Join Date: Jul 2004
Posts: 1,749
Reputation: nanosani is an unknown quantity at this point 
Solved Threads: 55
Team Colleague
nanosani's Avatar
nanosani nanosani is offline Offline
Unauthenticated Liar

Re: Any chance of a little help?

 
0
  #3
Aug 10th, 2004
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.
Reply With Quote Quick reply to this message  
Join Date: Aug 2004
Posts: 4
Reputation: scordle725 is an unknown quantity at this point 
Solved Threads: 0
scordle725 scordle725 is offline Offline
Newbie Poster

Re: Any chance of a little help?

 
0
  #4
Aug 10th, 2004
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.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:




Views: 2366 | Replies: 3
Thread Tools Search this Thread



Tag cloud for Java
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC