• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

Quick Java Question

Kenji4861

Banned
I'm programming elementary java material on the unix machine.

I have two files... main.java and methods.java

methods.java has all the methods I want to use in main.java

How do I "include" methods.java when I compile main.java

I use javac main.java to compile right now. Thanks!
 
LOL, I had the same question when I started using Java (switched to it from C++). You can't include files in Java. To the best of my knowledge, you need to use the "import" directive, but you can't just include methods or declares from a file line you could with .h in C++
 
No, create a class called something like MyMethods, and import that class. Declare the methods as static, and use them without even having to create an instance of MyMethods class.
 
Back
Top