-
Notifications
You must be signed in to change notification settings - Fork 328
Open
Description
重载和重写的区别
此处提及
重载
发生在同一个类中,方法名必须相同,参数类型不同、个数不同、顺序不同,方法返回值和访问修饰符可以不同。
但是返回值和访问限制符号不同好像会报错。
public class HelloWorld {
public void testFoo(){
}
public String testFoo() {
return "";
}
}
报错:Duplicate method testFoo() in type HelloWorld
Metadata
Metadata
Assignees
Labels
No labels