How to use the same function in several java classes? -
i can not understand how use same function in several java classes. example, have following function:
public int plus(int one, int two) { return 1 + two; }
how can use in several other files (classes)? should create in separate class?
if implementation going same (one+two), instead turn static method, this:
class util{ public static int plus(int one, int two) { return 1 + two; } }
then can call function
int result = util.plus(1,1)
Comments
Post a Comment