10-12-2009, 04:16 AM
Everybody is making this complicating.
I assume you just want to run a method that's in a different class than the one you are in currently.
In one class, you will have
Then, in the second class;
It's extremely simple stuff, so I havn't tested this code; I just typed it from the top of my head.
I assume you just want to run a method that's in a different class than the one you are in currently.
In one class, you will have
Code:
public class MyApp {
public static void main(String args[]) {
// Print: Testing:
Functions.print("Testing was: ");
// Check Value
if(Functions.check("test") ) { Functions.print("Successful!"); }
}
}
Then, in the second class;
Code:
public class Functions {
// Prints the given argument
public static void print(String s) { System.out.println(s); }
// Returns true if argument is "test"
public static boolean check(String query) {
if(query.equalsIgnoreCase("test") { return true; }
return false;
}
}
It's extremely simple stuff, so I havn't tested this code; I just typed it from the top of my head.