Results 1 to 4 of 4
  1. #1
    rajivjoshi's Avatar
    rajivjoshi is offline Member
    Join Date
    May 2010
    Posts
    13
    Rep Power
    0

    Red face illegal start of expression

    can anyone help me out i'm new to java and this error i'm unable to understand...
    showing Illegal start of expression


    public class rectangle
    {
    int length,width;
    public static void main(String args[])
    {
    void getData(int x,int y)
    {
    length=2;
    width=3;
    }
    int rectArea()
    {
    int area=length*width;
    return(area);
    }
    }
    }

  2. #2
    JosAH's Avatar
    JosAH is online now Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,526
    Blog Entries
    7
    Rep Power
    20

    Default

    Quote Originally Posted by rajivjoshi View Post
    public class rectangle
    {
    int length,width;
    public static void main(String args[])
    {
    void getData(int x,int y)
    {
    length=2;
    width=3;
    }
    int rectArea()
    {
    int area=length*width;
    return(area);
    }
    }
    }
    You can't define method getData( ... ) in the body of another method (here: main).

    kind regards,

    Jos

  3. #3
    rajivjoshi's Avatar
    rajivjoshi is offline Member
    Join Date
    May 2010
    Posts
    13
    Rep Power
    0

    Smile

    Thank you :):):):):)

  4. #4
    rajivjoshi's Avatar
    rajivjoshi is offline Member
    Join Date
    May 2010
    Posts
    13
    Rep Power
    0

Similar Threads

  1. Illegal Start of expression
    By Macca07 in forum New To Java
    Replies: 3
    Last Post: 11-23-2009, 08:43 AM
  2. Illegal start of expression
    By Basit56 in forum New To Java
    Replies: 2
    Last Post: 08-18-2009, 09:12 AM
  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 expression
    By razmyasdfg in forum CLDC and MIDP
    Replies: 2
    Last Post: 07-27-2008, 10:44 PM
  5. Illegal start of expression
    By gabriel in forum New To Java
    Replies: 2
    Last Post: 08-01-2007, 05:09 PM

Posting Permissions

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