File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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
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.
I agree. Here's the link:
subject: Array/Constructor Problem
It's not a secret anymore!