Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » Java Development Tools (JDT) » Arrays Now Break Code Check (Attempting To Use Arrays Sets Off Errors )
icon4.gif  Arrays Now Break Code Check [message #1733509] Sun, 29 May 2016 04:15 Go to next message
Rick S is currently offline Rick SFriend
Messages: 2
Registered: July 2014
Junior Member
Version: Indigo Service Release 2
Build id: 20120216-1857

Arrays now cause bugs ...
	
int[] x  =  new int[5]; 
x[0] = 1;

Produces these errors:
Quote:

Exception in thread "main" java.lang.Error: Unresolved compilation problems:
Syntax error on token ";", { expected after this token
Syntax error, insert "}" to complete ClassBody
at me.RLS0812.Testing.Test.<init>(Test.java:13)
at me.RLS0812.Testing.Main.main(Main.java:22)

http://s33.postimg.org/690jqvr1b/Eclipse_error.jpg
Re: Arrays Now Break Code Check [message #1733514 is a reply to message #1733509] Sun, 29 May 2016 10:32 Go to previous message
Stephan Herrmann is currently offline Stephan HerrmannFriend
Messages: 1853
Registered: July 2009
Senior Member
Rick S wrote on Sun, 29 May 2016 06:15
Arrays now cause bugs ...


No, there's no bug in JDT, and it's not the array that causes the error.
You are trying to implement statements in a position where Java does not admit statements.

The first line,
int[] x  =  new int[5];
is OK, this is a field declaration with initialization.

The second line,
x[0] = 1;
is a statement, this is illegal outside of method bodies and class/instance initializers. The solution is to put this statement into a new initializer, s.t. like this:
int[] x  =  new int[5];
{ // this starts an instance initializer
   x[0] = 1;
}


I admit that the error is raised at a suboptimal location, but then note that it says: "{ expected after this token" to signal that something is syntactically wrong after the semicolon.

best,
Stephan

PS: btw, indigo is quite old, you should really consider updating to a recent version of Eclipse, you are missing out on 4 years worth of bug fixes and enhancements.
Previous Topic:Problem creation WSDL with eclipse
Next Topic:Capture action "Run Last"
Goto Forum:
  


Current Time: Tue Oct 15 15:18:29 GMT 2024

Powered by FUDForum. Page generated in 0.03660 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top