Quick Java Question

Kenji4861

Banned
Jan 28, 2001
2,821
0
0
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!
 

VBboy

Diamond Member
Nov 12, 2000
5,793
0
0
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++
 

VBboy

Diamond Member
Nov 12, 2000
5,793
0
0
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.