permaculture playing cards*
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 OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Array/Constructor Problem" Watch "Array/Constructor Problem" New topic
Author

Array/Constructor Problem

Tom Jenner
Greenhorn

Joined: Jan 15, 2003
Posts: 4
I've pasted some code below that doesn't want to complile. Instead it gives the error messages.
Group3ObjectExperiment.java:7: illegal start of expression
new RunLengthCode(({53}), 1, 0),
^
Group3ObjectExperiment.java:11: ')' 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
Greenhorn

Joined: Jan 15, 2003
Posts: 4
Thanks, that now compiles.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Array/Constructor Problem