顺序很重要,因此具有不同顺序的相同参数的两个方法不被视为具有相同的签名.
例如,此示例不编译:
interface Foo {
void doIt(String what, int times);
}
class Bar implements Foo {
public void doIt(int times, String what) {}
}
Run Code Online (Sandbox Code Playgroud)
然而,参数的名称是无关紧要的.这很好:
interface Foo {
void doIt(String what, int times);
}
class Bar implements Foo {
public void doIt(String andNowForSomeThingCompetelyDifferent, int theLarch) {}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2988 次 |
| 最近记录: |