Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a Java equivalent to the 'new' modifier in C#? [duplicate]

Possible Duplicate:
Is there a ‘new’ modifier for methods in Java?

In c#, a subclass's method can be modified as new.

One usage of the new modifier to explicitly hide a member inherited from a base class.

Is there a same keyword in Java?

like image 450
roast_soul Avatar asked Jan 16 '13 06:01

roast_soul


People also ask

Does Java have an internal access modifier?

Java provides 4 levels of access modifiers. This means that you can modify access to a variable, method or a class in 4 ways. These 4 ways are private, public, protected and default.

Does Java have internal?

short answer is NO (but you can achieve it some how and i will tell)!! internal in C# is actually an "assembly-private" modifier. what is an assembly ? there is not any exact equivalent for internal in java.

What is final method in C#?

For final methods, use the sealed modifier. When you use sealed modifiers in C# on a method, then the method loses its capabilities of overriding. The sealed method should be part of a derived class and the method must be an overridden method.

What are internal methods in Java?

Two objects from the same class will have the same fields, constructors, and methods. Suppose we created a new Rectangle object, setting the length to 5 and the width to 10. If we call, or invoke, the area() method, the result will be 50 (length times width). This is an internal method call.


1 Answers

No.

In C# you use new to hide / shadow non-virtual functions of a base class. You need this keyword in C#, because you can not override functions that are non-virtual.

In Java, all functions are virtual by default, hence you can always override them and there is no need for a keyword such as new.

Hope this helps.

like image 187
Golo Roden Avatar answered Sep 23 '22 06:09

Golo Roden