Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Array/Constructor Problem

 
Tom Jenner
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3451
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try this:

Note the syntax for an anonymous array: new int[] {53}.
 
Tom Jenner
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks, that now compiles.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic