Results 1 to 10 of 10
  1. #1
    lukermsdn111 is offline Member
    Join Date
    Mar 2010
    Posts
    4
    Rep Power
    0

    Default 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 =)

  2. #2
    masijade is offline Senior Member
    Join Date
    Jun 2008
    Posts
    2,571
    Rep Power
    8

    Default

    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.

  3. #3
    lukermsdn111 is offline Member
    Join Date
    Mar 2010
    Posts
    4
    Rep Power
    0

    Default

    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?

  4. #4
    masijade is offline Senior Member
    Join Date
    Jun 2008
    Posts
    2,571
    Rep Power
    8

    Default

    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.

  5. #5
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    19

    Default

    Can you post the complete error message to see here? As masijade says the error is on a previous line of a code.

  6. #6
    lukermsdn111 is offline Member
    Join Date
    Mar 2010
    Posts
    4
    Rep Power
    0

    Default

    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.

  7. #7
    masijade is offline Senior Member
    Join Date
    Jun 2008
    Posts
    2,571
    Rep Power
    8

    Default

    Quote Originally Posted by lukermsdn111 View Post
    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.
    In your way, huh? In combination with your cross-posted topic in Daniweb?

  8. #8
    lukermsdn111 is offline Member
    Join Date
    Mar 2010
    Posts
    4
    Rep Power
    0

    Default

    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.

  9. #9
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    19

    Default

    You people really doing this? See how this person says that he found the solution by himself. I really hate that.

  10. #10
    masijade is offline Senior Member
    Join Date
    Jun 2008
    Posts
    2,571
    Rep Power
    8

    Default

    Quote Originally Posted by lukermsdn111 View Post
    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.
    It's not as long as the people answering are being told that the question has been asked elsewhere and what answers have already been given (and keep them up to date). No one likes wasting their time providing an answer or suggestion that has already been given.

Similar Threads

  1. Illegal start of expression
    By Basit56 in forum New To Java
    Replies: 2
    Last Post: 08-18-2009, 09:12 AM
  2. Servlet Error -illegal start of expression
    By raghu9198 in forum Java Servlet
    Replies: 2
    Last Post: 04-21-2009, 11:12 PM
  3. Illegal Start of an Expression
    By ddatta8 in forum New To Java
    Replies: 3
    Last Post: 12-20-2008, 08:40 PM
  4. Illegal Start of an Expression
    By David55 in forum CLDC and MIDP
    Replies: 8
    Last Post: 11-02-2007, 09:11 PM
  5. Illegal Start of an Expression
    By David55 in forum CLDC and MIDP
    Replies: 0
    Last Post: 04-20-2007, 05:59 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •