As you maybe know, as Java language perspective all method in C# are final by default (also vice versa, all methods in Java are virtual as C# language perspective).
In C# we can replace final (non-virtual) methods by new keyword (please see this). There is not anyway to replace final methods in Java?
Edit 1:
I just want to mention that method replacing is not same with method overriding. Please run this C# code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ComapreOverrideWithNew
{
class Program
{
static void Main(string[] args)
{
var cat = new Cat();
cat.PrintNameByNew();
Console.WriteLine(cat.GetNameByNew());
cat.PrintNameByOverride();
Console.WriteLine(cat.GetNameByOverride());
Console.ReadKey();
}
}
class Animal
{
public String GetNameByNew()
{
return "Animal";
}
public void PrintNameByNew()
{
Console.WriteLine(GetNameByNew());
}
public virtual String GetNameByOverride()
{
return "Animal";
}
public void PrintNameByOverride()
{
Console.WriteLine(GetNameByOverride());
}
}
class Cat : Animal
{
new public String GetNameByNew()
{
return "Cat";
}
public override String GetNameByOverride()
{
return "Cat";
}
}
}
For example http://docs.oracle.com/javase/tutorial/java/IandI/final.html is just talking about overriding. Also this code have not any compiler warning on compilation.
You cannot replace final methods in Java.