Java Package to include methods in other file -
I want to create a "library" of several methods that I have already written, and then use these methods in my second To Programs
A programming example is in C ++: You create a file header.HPP and a test.cpp, in the innside of test.cpp, you include methods using header.hpp: # Include "header.hpp".
There is no such option in Java, except the package but I do not know how it works. I do not want to use an actual OOP with the interface and implementation.
methods.java:
public class methods {// here in ways ...} > Pkg.java
package pkg; Public square pkg {public static zero function x (string x) {System.out.println ("hello", x); }} test.java
imported static pkg.A.m; Public class test {public static zero main (string agr []) {functionx ("name"); It is possible to import static methods in Java. For example: package pkg; Public square A {Public static zero () {// do stuff}} Then, you can import that method permanently:
Imported stable pkg .am; Class test {zero F () (m) (); // Use static library method}}
Comments
Post a Comment