Can someone please help me understand why the constructor of a class name Util
doesn’t work, yet it does for a class named Utility
?
I’m still wrapping my head around Eclipse. For a simple get to know how to use Eclipse to build my own processing libraries test I thought I’d just duplicate git’s processing-library-template-master's
HelloLibrary
class and rename the class to Util
. I also duplicated the example pde
file.
To my astonishment the example failed.
Being new at Eclipse, I wondered if I did something wrong. No, I don’t think so, everything looked right.
So I tried it again, this time thinking maybe I should spell out Util
to Utility
. And then it worked.
WTF?!
Here’s the code for each of the three classes:
HelloLibrary
package ccpd.library;
import processing.core.*;
public class HelloLibrary {
// myParent is a reference to the parent sketch
PApplet myParent;
public final static String VERSION = "##library.prettyVersion##";
public HelloLibrary(PApplet theParent) {
myParent = theParent;
welcome();
}
private void welcome() {
System.out.println("##library.name## ##library.prettyVersion## by ##author##");
}
public String sayHello() {
return "hello library.";
}
}
Util
package ccpd.utilities;
import processing.core.*;
public class Util {
// myParent is a reference to the parent sketch
PApplet myParent;
public final static String VERSION = "##library.prettyVersion##";
public Util(PApplet theParent) {
myParent = theParent;
welcome();
}
private void welcome() {
System.out.println("##library.name## ##library.prettyVersion## by ##author##");
}
public String sayHello() {
return "hello Util.";
}
}
Utility
package ccpd.utilities;
import processing.core.*;
public class Utility {
// myParent is a reference to the parent sketch
PApplet myParent;
public final static String VERSION = "##library.prettyVersion##";
public Utility(PApplet theParent) {
myParent = theParent;
welcome();
}
private void welcome() {
System.out.println("##library.name## ##library.prettyVersion## by ##author##");
}
public String sayHello() {
return "hello Utility.";
}
}
Here’s what they look like when the example for each is loaded:
I checked. Util
is not a reserved word, so what’s the problem?
Now I’m paranoid, wondering what other nasty and seemingly illogical surprises await me…