Reputation: 93
class Foo{
int[] doop;
public Foo(){
this.doop={1,2,3,4,5};
}
}
I can't compile this, Java ME SDK gives me a bunch of "Illegal Start of Expression" errors. Why? How do I make this work?
Upvotes: 7
Views: 20998
Reputation: 114
class Foo{
int[] doop;
public Foo(){
this.doop= new int[]{1,2,3,4,5};
}
}
Upvotes: 3
Reputation: 43108
You can't do this in constructor, because this syntax is allowed only for declaration with initialization. Fix to this:
class Foo{
int[] doop = new int[]{1,2,3,4,5};
public Foo(){
}
}
Upvotes: 4