How do you #include files in java?

You don’t #include in Java, you import package.Class. Since Java 6 (or was it 5?), you can also import static package.Class.staticMethodOfClass, which would achieve some forms of what you’re trying to do.

Also, as @duffymo noted, import only saves you from systematically prefixing the imported class names with the package name, or the imported static method names with the package and class name. The actual #include semantics doesn’t exist in Java – at all.

That said, having a “funcs.java” file seems to me like you are starting to dip your toes into some anti-patterns… And you should stay away from these.

Leave a Comment

tech