Reputation: 18046
I am new to Java and working in the Processing environment. I want to create a class that has a few objects in it, but I am getting an error when I try to construct those classes' object.
The bzaVertex
is supposed to be an object within the bza
object, but when I seemingly try to construct it, Processing says "The constructor sketch.BzaVertext(int) is undefined." I don't understand how Bza is getting its constructor called properly, but not the child object -- I seem to be calling them the same way?
I have this code all in the main class. I'm using Processing 2.0b7. What am I doing wrong?
Bza bza;
void setup() {
bza = new Bza();
}
public class BzaVertex {
public void BzaVertex(int d) {
}
}
public class Bza {
BzaVertex v1;
public void Bza() {
v1 = new BzaVertex(4);
}
}
Upvotes: 0
Views: 594
Reputation: 926
constructors do not have a return type so you need to to remove the void from both of them
class BzaVertex {
public BzaVertex(int d) {
}
}
class Bza {
BzaVertex v1;
public Bza() {
v1 = new BzaVertex(4);
}
}
public class Main
{
public static void main(String[] args)
{
Bza bza;
bza = new Bza();
}
}
that should solve the error
Upvotes: 3