Aryan Goharzad
Aryan Goharzad

Reputation: 187

How do I organize my Processing code in separate files?

I'm trying to code a big project using processing. I want to separate the files that contain groups of classes and methods. How do I include the separated files in my main processing file? I'm looking for something similar to "#include" in c++.

Upvotes: 3

Views: 2084

Answers (1)

Javier
Javier

Reputation: 12398

In java there may be only one (public) class per file. Classes are organized in packages, and packages are "nested" in a directory tree (just for convenience, since different packages are different, no matter where they are located).

Classes from other packages are not visible unless you import them. For instance, if you have your sources in src:

File /src/a/b/Class1.java contains:

package a.b;
public class Class1 {...}

In another class (let's say /src/x/Class2.java:

package x;
import a.b.Class1; //or import a.b.*;
public class Class2 {...}

Upvotes: 3

Related Questions