VB“Shadow”或C#“new”关键字在Java中的等效值是什么?
当我想定义一个非虚拟方法的新实现时,我可以在C#中使用new
关键字,或者在VB中使用shadow
关键字。例如:
C#代码:
public class Animal
{
public void MyMethod()
{
//Do some thing
}
}
public class Cat : Animal
{
public new void MyMethod()
{
//Do some other thing
}
}
VB代码:
Public Class Animal
Public Sub MyMethod()
'Do some thing
End Sub
End Class
Public Class Cat
Inherits Animal
Public Shadows Sub MyMethod()
'Do some other thing
End Sub
End Class
现在,我的问题是:
在Java中,VBShadow
(或C#new
)关键字的等价物是什么
共 (0) 个答案