Write a Java program to demonstrate method overloading with two methods having different data types
This Java code demonstrates method overloading, a feature that allows a class to have multiple methods with the same name but different parameters. In this example, the OverloadExample class has two print methods, each accepting a different type of parameter: one for int and one for double.
class OverloadExample { void print(int num) { System.out.println("Integer : " + num); } void print(double num) { System.out.println("Double : " + num); } public static void main(String[] args) { OverloadExample obj = new OverloadExample(); obj.print(18); obj.print(84.44); } }
Integer : 18 Double : 84.44
Learn All in Tamil © Designed & Developed By Tutor Joes | Privacy Policy | Terms & Conditions