Results 1 to 10 of 10
- 03-22-2010, 11:19 AM #1
Member
- Join Date
- Mar 2010
- Posts
- 4
- Rep Power
- 0
Illegal start of expression error
Hi, im a total Java beginner and was just hoping someone could help me work out why i'm getting an 'illegal start of expression' error on the first line:
(public boolean isFull()) of this code:
Java Code:public boolean isFull() { for (int a = 0; a < 10; a++) { for (int a2 = 0; a2 < 10; a2++) { if(cacheDataArray[a][a2] == 0) { return false; } else { return true; } } } } if (isFull()) //Code which only runs if the cache is full { for (int b = 0; b < 10; b++) { for (int c = 0; c < 10 c++) { if (cacheDataArray[b][c] == lruArray[0]) { cacheDataArray[b][c] = testData[j]; } } } }
Theres more code than that in the program, just didnt want to go overkill on the code. If there aren't any apparent errors in this code Ill put the rest =)
- 03-22-2010, 11:22 AM #2
Senior Member
- Join Date
- Jun 2008
- Posts
- 2,366
- Rep Power
- 7
Yeah, well the problem is on some line before this. Usually either a missing ";" at the end of a statement, or a missing closing ")", "]", or "}" at the end of a respective block.
- 03-22-2010, 11:27 AM #3
Member
- Join Date
- Mar 2010
- Posts
- 4
- Rep Power
- 0
Hey, thanks for the quick reply. Ive had a thorough look and can't see any missing brackets or semi-colons. Would it have anything to do with the method 'isFull()' being called from within another method?
- 03-22-2010, 11:59 AM #4
Senior Member
- Join Date
- Jun 2008
- Posts
- 2,366
- Rep Power
- 7
If you mean declared/defined, and not called, yes. You can't do that. You also can't declare anything "public, private, protected, or static" from within a method.
- 03-22-2010, 12:47 PM #5
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
Can you post the complete error message to see here? As masijade says the error is on a previous line of a code.
- 03-22-2010, 12:49 PM #6
Member
- Join Date
- Mar 2010
- Posts
- 4
- Rep Power
- 0
I have just worked out the error in my ways, but many thanks for the reply. I was declaring a method within another method and thus the error message.
- 03-22-2010, 01:18 PM #7
Senior Member
- Join Date
- Jun 2008
- Posts
- 2,366
- Rep Power
- 7
- 03-22-2010, 01:22 PM #8
Member
- Join Date
- Mar 2010
- Posts
- 4
- Rep Power
- 0
Sorry, I didnt realise it was a sin to cross-post. I was merely in search of an answer and thought it judicious to ask around wherever I could.
- 03-22-2010, 01:24 PM #9
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
You people really doing this? See how this person says that he found the solution by himself. I really hate that.
- 03-22-2010, 01:31 PM #10
Senior Member
- Join Date
- Jun 2008
- Posts
- 2,366
- Rep Power
- 7
Similar Threads
-
Illegal start of expression
By Basit56 in forum New To JavaReplies: 2Last Post: 08-18-2009, 09:12 AM -
Servlet Error -illegal start of expression
By raghu9198 in forum Java ServletReplies: 2Last Post: 04-21-2009, 11:12 PM -
Illegal Start of an Expression
By ddatta8 in forum New To JavaReplies: 3Last Post: 12-20-2008, 08:40 PM -
Illegal Start of an Expression
By David55 in forum CLDC and MIDPReplies: 8Last Post: 11-02-2007, 09:11 PM -
Illegal Start of an Expression
By David55 in forum CLDC and MIDPReplies: 0Last Post: 04-20-2007, 05:59 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks