Results 1 to 4 of 4
- 11-25-2010, 10:50 PM #1
Member
- Join Date
- Nov 2010
- Posts
- 2
- Rep Power
- 0
"not a statement" error to array declaration
I'm getting a "not a statement" error pointing at the first square bracket in the following statement:
int[] final = new int[first.length + second.length];
("first" and "second" are other arrays)
In addition to the "not a statement" error, I'm getting seven other errors pointing at this statement alone, including " ; expected" and "[ expected". However, I think these are a direct result of the first error. Can anyone help me?
Also, I tested this line using an integer for the length instead of an expression, and it still didn't work.
- 11-25-2010, 10:56 PM #2
Member
- Join Date
- Aug 2010
- Posts
- 15
- Rep Power
- 0
Hey!
final, in Java, makes a variable a constant.
for instance, "final int stg = 2;" makes stg always equal to 2, and nothing your program does can modify it (hence the term final/constant).
change your variable name to something other than final (last, maybe?). that should help. Java doesn't allow you to name variables after modifiers and the like ("int static" doesn't work, for example).
I also recommend getting an IDE like Eclipse. it will catch these minor mistakes you'll make. extremely useful, even when you're more experienced with programming.Last edited by adhoc334; 11-25-2010 at 10:59 PM.
- 11-25-2010, 10:58 PM #3
Member
- Join Date
- Nov 2010
- Posts
- 2
- Rep Power
- 0
Arrgh, I am a fool! I should have known this! *facepalm* Thanks for the help
- 11-25-2010, 11:01 PM #4
Member
- Join Date
- Aug 2010
- Posts
- 15
- Rep Power
- 0
Similar Threads
-
An "if" statement inside a "for" loop?
By soccermiles in forum New To JavaReplies: 18Last Post: 04-20-2010, 03:44 AM -
Runtime error "Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 0
By shantimudigonda in forum New To JavaReplies: 1Last Post: 11-20-2009, 07:58 PM -
Simple "if" statement problem....compiling error.
By CYANiDE in forum New To JavaReplies: 4Last Post: 10-14-2009, 09:56 PM -
[SOLVED] Why does the compiler return "not a statement" for this method body please?
By trueblue in forum New To JavaReplies: 3Last Post: 05-25-2009, 08:50 PM -
the dollar sign "$", prints like any other normal char in java like "a" or "*" ?
By lse123 in forum New To JavaReplies: 1Last Post: 10-20-2008, 07:35 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks