+ 5

Java: Can I use a function in a different .java file?!

my code is way too long so i need to write some of it in other files. How can I link these docs and call the function in the other file and than receive one or multiple new strings?

26th Oct 2018, 12:57 PM
Ole
3 Antworten
+ 10
This might help you ;) If you have any further questions just ask. https://www.sololearn.com/learn/Java/2161/?ref=app
26th Oct 2018, 8:39 PM
Tashi N
Tashi N - avatar
+ 5
How to run java class file which is in different directory? In this article we will learn about how to use other project’s utilities, classes and members. Before proceeding let’s learn about some keywords. classpath Classpath is the location from where jvm starts execution of a program. Similar to the classic dynamic loading behavior, when executing Java programs, the Java Virtual Machine finds and loads classes lazily (it loads the bytecode of a class only when the class is first used). The classpath tells Java where to look in the filesystem for files defining these classes. Variables and methods which are accessible and available at classpath are known as classpath variables. By default JVM always access the classpath classes while executing a program. JVM always go into the deep of classpath to search a class or resource.
27th Oct 2018, 11:11 AM
Florinn
Florinn - avatar
0
If your classes are in the same Project you can declare your Methods as static an then you can use it in your other classes Classname.staticMethod(maybe some Parameters)
4th Nov 2018, 3:47 AM
Sebastian
Sebastian - avatar