开发者

Syntax error on ; when allocating an array

开发者 https://www.devze.com 2023-02-27 11:01 出处:网络
I\'m getting an error in Eclipse when trying to ini开发者_C百科tialize the following array in the initializing section of my class:

I'm getting an error in Eclipse when trying to ini开发者_C百科tialize the following array in the initializing section of my class:

Color[] colors;
colors = new Color[4];

This is the error I'm getting:

Syntax error on token ";", , expected

Where ";" refers to the semicolon on the first line. Tried different variable types, gave the same error. Here's some code on the official JDK tutorial section that seems the same to me:

http://download.oracle.com/javase/tutorial/java/nutsandbolts/arrays.html

Thanks in advance, guys.


This is a correct syntax and does compile.

(Maybe the line before is a problem. Can you post it too)

0

精彩评论

暂无评论...
验证码 换一张
取 消