2.6.3 static keywordGenerally, when creating a class, we will point out the appearance and behavior of the Class Object. Unless you use new to create an object for that class,Otherwise, you will not actually get anything. The data storage space will
Reference 55049192This explains why an enumeration class cannot be inherited: it has inherited the parent enum class, and its parent implements the serializable interface, which means that all enum classes implement serializationThe Enum class also
Question one: Can Java constructors be inherited?The author of Java read a book said: "Java subclasses naturally inherit its superclass" non-private members.Normally Java constructors are set to public (if you do not write the constructor, Java
Package com.hanwei.service;
Class testparent{public
testparent () {
System.out.println ("I am a parameterless constructor for the parent class");
}
Public Testparent (String a) {
System.out.println
static keyword for Java
In Java, the static-decorated member variables and member methods are called static variables and static methods, and are not dependent on class-specific instances and are shared by all instances of the class.
static
The first conclusion is that static properties and static methods in Java can be inherited, but not rewritten (overwrite) but hidden. Static methods and properties belong to the class, and are called directly through the class name. The method name
Key concepts: Abstract classes, abstract methods, static classes, static internal classes, static methods, static variables, constants, global constants.
I. The use of abstract, modifier, you can modify class and Method 1, abstract modifier class,
Code reuse is implemented through inheritance. All classes in Java are obtained by inheriting the Java.lang.Object class directly or indirectly. Inherited classes are called subclasses, and inherited classes are called parent classes. Subclasses
The common methods and member variables here refer to non-static methods and non-static member variablesFirst, Static is the meaning, is a modifier, can be used to modify variables or methods.Static member variables have global variables that do not
Java static, this, super, final usage
I. Static
Take a look at the following program:
Public class Hello {Public static void main (string [] ARGs) {// (1)System. Out. println ("Hello, world! "); // (2)}}
I have read this program,
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.