Case 5 Overloading - rahul00773/JavaConcepts GitHub Wiki

class Test{

public void m1(int x){

System.out.println(“general method”); }

public void m1(int…… x){

System.out.println(“var arg method”); }

}

class T{ public static void main(String[] args){

Test T = new Test();

T.m1();// var arg method

T.m1(10,10);// var arg method

T.m1(10)// General Method

} }

In General var arg method will get the least priority. That is if no other method matched then only var arg method will get the chance. It is exactly the same as the default case inside the switch.