public class Test { public static void printValue(int i, int j, int k) { System.out.println("int"); } public static void printValue(byte...b) { System.out.println("long"); } public static void main(String... args) { byte b = 9; printValue(b,b,b); } }
The output of the above code is "int". But it must be "long" because the function of the byte type argument is already present. But here the program promotes byte values ββto int, but it should not be.
Please can anyone clarify what is going on here?
java method-overloading variadic-functions
Shipra varshney
source share