+ 2
How to call function without creating object in java ?
please give code
3 Answers
+ 21
//use static keyword while defining the function
public class Program {
public static void func() {}
public static void main(String[] args) {
func(); // method call
}
static void func () {statement (s);} //method definition
}
//hope u got it buddy âș & mark john sir answer as best , i derived answer from him only
+ 3
public class Program {
public static void func() {}
public static void main(String[] args) {
func(); // Calling function
}
}