I'm creating anonymous array and passing it to a method which is declared to receive a variable argument character...
I'm wondering how the below code will run successfully, I'm passing a array of characters {'A','B','C,'D'} and the method can receive only characters...shouldn't it fail with wrong types passed? ie; character array vs characters?
public class test {
public static void main(String[] args) {
callme(new char[]{'A','B','C','D'});
}
static void callme(char... c){
for (char ch:c){
System.out.println(ch);
}
}
}
char...is some sweet sugar.