Results 1 to 3 of 3
  1. #1
    DudeJericho is offline Member
    Join Date
    Apr 2011
    Location
    London
    Posts
    5
    Rep Power
    0

    Default Very annoying error for array assignment

    I don't know why but I keep getting a syntax error when I'm trying to assign the first position of an array I made saying "Syntax error on token ";",{ expected after this token", but taking off the "strokePos[0] = 1 ;" doesn't give that error, does anyone have an idea as to why this is? Thanks in advance.

    Java Code:
    	JMenuBar menuBar ;
    	JMenu menuSession ;
    	JMenuItem subNewGame, subLoadGame ;
    	MyComponent graphArea ;
    	Color one = Color.blue ;
    	Color two = Color.blue ;
    	Color three = Color.blue ;
    	Color four = Color.blue ;
    	int firstx[]={275,325,325,275} ;
    	int firsty[]={100,100,175,175} ;
    	int secondx[]={150,450,450,150} ;
    	int secondy[]={180,180,230,230} ;
    	int thirdx[]={255,292,180,143} ;
    	int thirdy[]={263,300,412,375} ;
    	int fourthx[]={345,308,420,457} ;
    	int fourthy[]={263,300,412,375} ;
    	Polygon firstStroke = new Polygon(firstx,firsty,4) ;
    	Polygon secondStroke = new Polygon(secondx,secondy,4) ;
    	Polygon thirdStroke = new Polygon(thirdx,thirdy,4) ;
    	Polygon fourthStroke = new Polygon(fourthx,fourthy,4) ;
    	int s1, s2, s3, s4 ;
    	int[] strokePos = new int[4] ;
    	strokePos[0] = 1 ;
    The problem of course lies within the last two lines.

  2. #2
    r035198x is offline Senior Member
    Join Date
    Aug 2009
    Posts
    2,388
    Rep Power
    7

    Default

    You can't do that outside a method or constructor. You are only allowed declarations and that is an assignment, the rest are declarations.

  3. #3
    DudeJericho is offline Member
    Join Date
    Apr 2011
    Location
    London
    Posts
    5
    Rep Power
    0

Similar Threads

  1. Match Generator Assignment Help / Error Message
    By kittykat850 in forum New To Java
    Replies: 9
    Last Post: 04-20-2011, 05:34 PM
  2. Annoying Popups
    By camickr in forum Suggestions & Feedback
    Replies: 24
    Last Post: 03-01-2011, 03:58 PM
  3. Annoying problem class/interface error
    By Chick786 in forum New To Java
    Replies: 2
    Last Post: 04-11-2010, 04:36 PM
  4. Insanely annoying java error...
    By Nukleahboy in forum New To Java
    Replies: 10
    Last Post: 08-07-2009, 09:22 AM
  5. help with fixing my assignment.please...error
    By Jin-enigma-PL in forum New To Java
    Replies: 4
    Last Post: 02-05-2009, 12:12 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
  •