Java-Method Overloading

Method Overloading Method overriding occurs only when the names and the types signatures of the two methods are identical. If they are not, then the two methods are simply overloaded. Program Program Source class Data { int data1; int data2; void dataValues() { System.out.println(“data1 = “+data1); System.out.println(“data2 = “+data2); } } class NewData extends Data … Read more…

Java-Variable Length Arguments(Method Overloading)

Variable Length Arguments (Method Overloading) Just like normal methods, java ¬†provides facility to overload vararg¬†methods also. You can overload a method with a variable length arguments as long as the parameters for the methods differ in type or order. For example : void varArgsTest(int…v){} void varArgsTest(boolean…v){} void varArgsTest(String…v){} The types of its varargs parameter can … Read more…

Java-Method Overloading

Method Overloading Two or more methods in a class with the same name but different parameter. This technique is called method overloading. Method overloading is used when objects are required to perform similar tasks but using different input parameters. When we call a method in an object, Java matches up the method name first and … Read more…