I believe many of my friends will encounter problems related to @ overide when using eclispe to develop Java projects.
The error format is as follows:
The method *** of Type *** must override a superclass Method
At this time, this method actually overwrites the method of a parent class, so this error will be confusing.
But in fact, the reason is very simple:
Because your compiler is JDK 5, and 5 does not support the @
Copy Code code as follows:
public class Father
{
public void Write () {
Console.WriteLine ("Father");
}
}
public class Mother{public virtual void Write (){Console.WriteLine ("Mother");}}
public class Boy:father{Public new void Write (){Console.WriteLine ("Zi");}}
public class Girl:mother{public override void Write (){Console.WriteLine ("Female");}}
Copy Code code as follows:
static void Main (string[] args)
{
Father Fa
. Out. println ("~~~~~~~~~~~~~~ ");Demo3 D3 = new demo3 (3 );D3.fun1 (); // demo2 inherits all methods of the parent class demo1 and super parent classes.D3.fun2 ();D3.fun3 ();System. Out. println ("~~~~~~~~~~~~~~ ");Demo1 D11 = new demo2 (2 );D11.fun1 (); // method in demo2 to override the method in demo1; otherwise, only the demo1 method is available.System. Out. println ("------------");Demo1 d111 = new demo3 (3 );D111.fun1 (); // The method in dem
Just in touch with C # programming, I was also bewildered by the override and new. So took a little time to turn over the information, read the blog, and finally a small understanding, the study notes recorded here.First declare a parent class animal class, and inherit the animal two subclass of the dog class with the Cat class. There is a say method in the parent class animal, and the subclass Dog and Cat overrid
In this article, I will show you my understanding of the hashcode and equals methods. I will discuss their default implementations and how to rewrite them correctly. I will also use the Toolkit provided by Apache commons for implementation.
Directory:
Hashcode () and equals () Usage
Override default implementation
Use the Apache commons lang package to override hashcode () and equals ()
Things to remem
First, rewrite (override) Override is a way to override (overwrite) a method to implement different functions. It is generally used to override (re-implement) a method in the parent class when the subclass inherits the parent class.Override (Overwrite) the rule:1. The parameter list of the overridden method must be exa
ExtJs -- 16 -- Ext. override () method specifically used to override the object Method
Ext. onReady (function () {/*** Ext. the override () method is specifically used to override the object Method * // defines a class Ext. define ("U", {// attribute configuration item config :{}, // method of this class show: functio
overloaded, and cannot be distinguished as an overloaded function by the type of the return value.
cannot be overloaded by access rights.
Override (override, overwrite)
The polymorphism between the subclass and the parent class, the method of the parent class is redefined, is the diversity of the runtime. If a method defined in a subclass has the same name and parameters as its parent cla
Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->/*
* Created by sharpdevelop.
* User: noo
* Date: 2009-8-16
* Time: 16: 40
*
* Hide and override (the keywords are new and override respectively)
*/
Using system;Class newa{Public Virtual void output1 (){Console. writeline ("base class method 1 ");}Public void output2 (){Console. writeline ("base class method
1.Java Development environmentIf you are using eclipse to develop a Java project, the following error occurs when you use the @Override:The method * * * of type * * * must override a superclass methodMainly because your compiler is JDK5, (5 does not support @override and other forms of annotations) just change it to 6.Method: Change the compiler compliance level in Window->preferences->java-compiler to 6.0.
Original URL: http://www.blogjava.net/anchor110/articles/339352.htmlIf you are using eclipse to develop a Java project, the following error occurs when you use the @Override:The method * * * of type * * * must override a superclass methodMainly because your compiler is JDK5, (5 does not support @override and other forms of annotations) just change it to 6.Method: Change the compiler compliance level in Wind
Method overload (override)/method override, magic function implementation, and heavy-load magic
Method overloadDifferent function names use different numbers or types of functions to call the same function name, but different functions can be distinguished.Class {Public function test1 (){Echo "test1 ";}Public function test1 ($ ){Echo "test1 hhh ";}}
Heavy Load$ A = newA ();$ A-> test1 ();$ A- gt; test1 (222
Cause tracking and resolution:1. Access to the data found that the use of @override under the jdk1.5 annotation must ensure that the method being labeled is derived from class rather than interface.2. Even if your JDK is 1.6, you will need to modify the compiled JDK version in MyEclipse and change from 1.5 (5.0) to 1.6 (6.0), or else the above error may occur.Liberation method: Under MyEclipse: Windows-preferences-java Compiler, on the right of the Co
Cause tracking and workaround:1. Access to data found that the use of @override under the jdk1.5 annotation must ensure that the method being labeled is derived from class rather than interface.2. Even if your JDK is 1.6, you will need to modify the compiled JDK version in MyEclipse and change from 1.5 (5.0) to 1.6 (6.0), or else the above error may occur.Liberation method: Under MyEclipse: Windows-preferences-java Compiler, on the right of the Compil
Copy codeThe Code is as follows: public class Father
{
Public void Write (){
Console. WriteLine ("parent ");
}
}
Public class Mother{Public virtual void Write (){Console. WriteLine ("mother ");}}
Public class Boy: Father{Public new void Write (){Console. WriteLine ("sub ");}}
Public class Girl: Mother{Public override void Write (){Console. WriteLine ("female ");}}
Copy codeThe Code is as follows: static void Main (string [] args){Father father = new
Http://www.cnblogs.com/qlee/archive/2011/07/04/2097055.htmlOverloading, overwriting, and hiding of member functionsThe overloading, overwriting (override) and hiding of member functions are easily confused, and C + + programmers have to figure outconcept, otherwise errors will be impossible to guard against.8.2.1 Overloading and overwritingFeatures that are overloaded by member functions:(1) The same range (in the same class);(2) The function has the
A, what is method overloading? (in the same Class) method overloading refers to the case where the same method name appears in the same class, with a different argument list.B, what is method coverage? A method override in a child-parent class is a function that runs a subclass when a method declaration is identical to the parent class, which is called a overwrite operation.Method overrides occur between the parent class and the subclass with the inhe
this point, the function of the base class is hidden, regardless of the virtual keyword (Note that it is not confused with overloading).(2) If the function of the derived class has the same name as the function of the base class, and the parameters are the same , the base class function does not have the virtual keyword. At this point, the function of the base class is hidden (be careful not to confuse the overlay).Cases:#include using namespacestd;classbase{ Public: Virtual voidFfloatx) {co
1 Rules to override:1) The "Return value type method name (parameter list)" of the subclass method must be the same as the parent class method2) The modifier of the subclass method cannot be less than the modifier of the parent class method3) If the parent method throws an exception, the subclass method throws an exception type that cannot be greater than the parent class4) The Child parent class method must be either static or non-static5) The method
Overload: Implements multiple versions of a function. The Compiler determines when to call a function. The return value of a function is not used as a basis to distinguish between overloaded functions.
Override: implements the same function as the parent class signature in the subclass.
Overloading is when you make multiple versions of a function. The Compiler figures out which function to call. Overloading does not take return type to differentia
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.