User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the Java section within the Software Development category of DaniWeb, a massive community of 456,526 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,807 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Java advertiser: Lunarpages Java Web Hosting
Views: 1925 | Replies: 3
Reply
Join Date: Aug 2004
Location: sheffield
Posts: 1
Reputation: steventhms is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
steventhms steventhms is offline Offline
Newbie Poster

Help Any chance of a little help?

  #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;
}
}
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Aug 2004
Posts: 4
Reputation: scordle725 is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
scordle725 scordle725 is offline Offline
Newbie Poster

Re: Any chance of a little help?

  #2  
Aug 10th, 2004
I'm not sure. I was able to compile without any errors.
Reply With Quote  
Join Date: Jul 2004
Location: Pakistan
Posts: 1,673
Reputation: nanosani is an unknown quantity at this point 
Rep Power: 8
Solved Threads: 50
Colleague
nanosani's Avatar
nanosani nanosani is offline Offline
Unauthenticated Liar

Re: Any chance of a little help?

  #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  
Join Date: Aug 2004
Posts: 4
Reputation: scordle725 is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
scordle725 scordle725 is offline Offline
Newbie Poster

Re: Any chance of a little help?

  #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  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb Java Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the Java Forum

All times are GMT -4. The time now is 4:14 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC