+ 2
Help ! Example of main function overloading
Can main method be overloaded in java The basic signature of the main can be changed like public static void main (int args ) Will that be fine or how can we overload it
4 Answers
+ 6
Maybe this link can help..
https://www.java67.com/2015/06/can-you-overload-or-override-main-in-java.html?m=1
+ 3
yes you can
import java.util.Arrays;
public class Program {
public static void main(String[] args) {
System.out.println( "main String" +Arrays.toString(args) );
main(new int[]{10});
}
public static void main(int[] args) {
System.out.println( "main int" +Arrays.toString(args) );
}
}
output:
main String[]
main int[10]
+ 3
Thank u guyz for ur help! :)