In processing, I have defined the following class:
class SomeClass {
SomeClass(int[] someArray) {
println(someArray);
}
}
N
You still need to define it somehow before you send it in... Try this:
SomeClass myVar = new SomeClass(new int [] {
12, 10
});
or you could try some of Java's syntactic sugar...
class SomeClass {
SomeClass(int... someArray) {
println(someArray);
}
}
SomeClass myVar = new SomeClass(12, 10);
which will introduce some restrictions to your coding style... For example you can do this: (special syntax as the last element)
class SomeClass {
SomeClass(String someString, float someFloat, int... someArray) {
println(someString);
println(someFloat);
println(someArray);
}
}
SomeClass myVar = new SomeClass("lol",3.14, 12, 10);
but not this: (special syntax not as the last element)
class SomeClass {
SomeClass(String someString, int... someArray, float someFloat) {
println(someString);
println(someFloat);
println(someArray);
}
}
SomeClass myVar = new SomeClass("lol", 12, 10,3.14);
Arrays are fun!!