This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Array/Constructor Problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Array/Constructor Problem" Watch "Array/Constructor Problem" New topic

Array/Constructor Problem

Tom Jenner

Joined: Jan 15, 2003
Posts: 4
I've pasted some code below that doesn't want to complile. Instead it gives the error messages. illegal start of expression
new RunLengthCode(({53}), 1, 0),
^ ')' expected
new RunLengthCode(({176}), 1, 4),
I think its a syntax problem but I may be way off. Can anyone tell me what I'm doing wrong. Many thanks. - Tom
--Code is as follows--
class Group3Object
//Run length code arrays
RunLengthCode[] whiterunlengthcodes = {
new RunLengthCode({53}, 1, 0),
new RunLengthCode({28}, 1, 2),
new RunLengthCode({112}, 1, 4),
new RunLengthCode({128}, 1, 4),
new RunLengthCode({176}, 1, 4),
public Group3Object()

class RunLengthCode
int[] code;
int length;
int offset;

RunLengthCode(int[] s, int i, int j)
this.code = s;
this.length = i;
this.offset = j;
Michael Morris
Ranch Hand

Joined: Jan 30, 2002
Posts: 3451
Try this:

Note the syntax for an anonymous array: new int[] {53}.

Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius - and a lot of courage - to move in the opposite direction. - Ernst F. Schumacher
Tom Jenner

Joined: Jan 15, 2003
Posts: 4
Thanks, that now compiles.
It is sorta covered in the JavaRanch Style Guide.
subject: Array/Constructor Problem
Similar Threads
How do I handle "The Matrix" ?
array question
Can anyone explain this code from ...Java 2 Part-1 the programmers exam - page 49
question from kathy/bates book
Floyd's Algorithm