Output is always In OBJECT. since the return type is void in all cases.
But why is it not going to m1(Integer s)? And without typecasting is it possible to make the call go to m1(Integer s)?
package test;
public class test_class {
public static void m1(Integer s){
System.out.println("IN INT");
}
public static void m1(Object s){
System.out.println("IN OBJECT");
}
public static <Integer> void m2(Integer t){
m1(t);
}
public static void main(String[] args) {
// TODO Auto-generated method stub
test_class.m2(12);
}
}
<Integer>inpublic static <Integer> voiddoes? Why do you think so?<Integer>creates a named generic type (and that then shadowsjava.lang.Integer). Why are you making that a generic method? And why did you name the typeInteger?Integer. To illustrate, these two declarations are the same:<Integer> void m2(Integer t)and<Foo> void m2(Foo t)