Yes,
you can overload main method of a class.
Application.java
package com.sample.app; public class Application { public static void main(int a) { System.out.println("Value of a is : " + a); } public static void main(float b) { System.out.println("Value of b is : " + b); } public static void main(double c) { System.out.println("Value of c is : " + c); } public static void main(String args[]) throws Exception { main(10); main(10.02f); main(10.02); } }
Output
Value
of a is : 10
Value
of b is : 10.02
Value
of c is : 10.02
You may like
No comments:
Post a Comment