public class OverLoad {
void method(Integer i){
System.out.println("Integer "+i);
}
void method(int i){
System.out.println("in "+i);
}
public static void main(String a[]){
OverLoad m= new OverLoad();
m.method(2); //it calls method(int i) why?
}
}
Run Code Online (Sandbox Code Playgroud)
如果我调用m.method(3)它会调用int方法为什么?如果我调用m.method((Integer)3)那么它将调用Integer方法.
默认情况下,它将进入原始数据类型
org.apache.cxf.jaxrs.ext.multipart.Attachment attachments=null;
List<Attachment> clone = new ArrayList<Attachment>(attachments.size());
for(Object item: attachments)
clone.add((Attachment)item.clone());//The method clone() from the type Object is not visible
Run Code Online (Sandbox Code Playgroud)
我想克隆该List<Attachment> clone对象,但它说来自Object类型的方法clone()是不可见的