this abstract method FANGFA () in the main method.Abstract modifierAbstract Class:An abstract class cannot be used to instantiate an object, and the sole purpose of declaring an abstract class is to augment the class in the Futur
and methods in the class.3. If there is a local variable in the local internal class blocking method, the local variable cannot be accessed within the local internal class.
Anonymous internal classCallback method, internal class without class name1. There is only one non-ar
functions, the abstract class is named abstract class, without the concept of pure, but invented a kind of called interface interface to replace the pure virtual class. The difference
The problem that this paper solves
What is abstract class
Application Scenarios for abstract classes
Can interfaces be implemented in a method?
The difference between an interface and an abstract class
1
In the Java language, abstract classes and interface are the two mechanisms that support the definition of an abstraction class. It is the existence of these two mechanisms that gives Java a powerful object-oriented capability. Abstract
java– virtual functions, abstract functions, abstract classes, interfaces
1. Java virtual functions
The existence of virtual functions is for polymorphism.
C + + Ordinary member function plus virtual keyword becomes virtual function
In Java, there is no concept of virtual
1. Java virtual functionsThe existence of virtual functions is for polymorphism.C + + the normal member function plus Virtual The keyword becomes a virtual functionjava c++ java java final keyword becomes non-virtual function PS: actually C + + and the Java The point of view in virtual function is similar.
All properties in the interface are public static final, and the methods are public. The access modifier must be either the public interface or the other interface, similar to the inheritance of the class, the keyword extendsHttp://www.cnblogs.com/dolphin0520/p/3811437.htmlDeep understanding of
HEAD first this series of books, really let people produce the pleasure of reading ~ ~:)The same as the science of tomorrow.InterfaceNose { Public intIMethod ();}Abstract classPicassoImplementsNose { Public intIMethod () {return7; }}classClownsextendsPicasso {//Pass}classActsextendsPicasso { Public intIMethod () {return5; }} Public classDotcombustextendsClowns { Public Static voidmain (String [] args) {Nose [] I=NewNose [3]; i[0] =NewActs (); i[1] =Ne
implementation of the situation.3, achieve multi-inheritance effect.ExampleAn example of a abstract class in the JDK are Abstractmap, which is part of the collections Framework. Its subclasses (which include HashMap, TreeMap, and Concurrenthashmap) share many methods (including get, put, IsEmpty, CO Ntainskey, and Containsvalue) that Abstractmap defines.An example of a
probably the only advantage of Java Abstract classes, however, this advantage is very useful. For example, if a new method is added to an abstract class, all its subclasses will get this new method at once, and the Java interface
extends Fruit {
@Override
public void weight () {
System.out.println ("fruit weight");
}
}
This class inherits the price () method of the class fruit and implements the weight () method of the fruit abstract class.
Inheriting an interface
interface . Abstract class
In object-oriented concepts, all objects are depicted by classes, but conversely, not all classes are used to depict objects , and if a class does not contain enough information to depict a specific object, such a class is an
(i) overviewIn the Java language, abstract classes and interface are the two mechanisms that support the definition of an abstraction class. It is precisely because of the existence of these two mechanismsIn order to give Java a powerful object-oriented capability. The
(1) OverviewAbstract class and interface support the definition of abstract classes in Java. It is precisely because of the existence of these two mechanisms
Only in this way can Java provide powerful object-oriented capabilities. Abstra
is probably the only advantage of Java Abstract classes, however, this advantage is very useful.If a new concrete method is added to an abstract class, all its subclasses will get this new method at once, and the Java interface c
(Source http://hi.baidu.com/dgx_lsyd3/blog/item/8f710ed7ca49badda144dfd0.html)
---------------------------------------------Explanation 1:Abstract class and interface are two mechanisms supported for the definition of abstract classes in Java. It is precisely because of the
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.