{ System.out.println ("Class B is initialized");//output }}class A extends B { static { System.out.println ("Class A is initialized"); Do not output }}public class Superclasstest {public static void Main (string[] ar
Java is a single inheritance language, but in the inheritance relationship of subclasses, there are cases where the parent class and the interface have the same method.
Let's take a step-by-step validation:
1. Subclass inherits the parent class, implements the interface, and the parent class and interface have the sa
Java Abstract class and java Abstract
What is an abstract class? This name is very abstract. The first time I heard this name, it may be blocked. However, as the old man said, all anti-sprees are paper tigers, and the concept of dressing x is also a paper tiger. Well, we have already put down on it strategically. Now
Class loading is one of the most powerful mechanisms provided by the Java language. Although class loading is not a hot topic, all programmers should understand its working mechanism and understand how to make it meet our needs. This effectively saves our coding time and frees us from the work of continuously debugging classnotfoundexception and classcastexceptio
FinalKeyword as a modifier1. You can modify classes, functions, variables2. A class that is final modified cannot be inheritedIn order to avoid being inherited, quilt-like replication function.3. Final modification of the method, can not be replicated4. The final modified variable is a constant that can be assigned only once, either to modify the member variable or to modify the local variable. As constants: The writing specification for constants: Al
Java basics 9-abstract class, java-AbstractJava basics 9-abstract class 1. Introduction to abstract classes
/*Abstract class:Abstract: general, fuzzy, and incomprehensible! Not specific.
Features:1. MethodOnly declarations are not implementedThis method isAbstract Method, Need to beAbstract.Abstract methods must be de
Public class Animal {Public static void Main (string[] args) {Animal Animal = new Cat ();Animal.voice ();Drinkwater (animal); Call a static method, passing in a subclass object referenced by the parent class }String str;Public void Voice () {System.out.println ("Ordinary animal cries!") "); }Public static void Drinkwater (Animal Animal) {//static method, passed in Animal parent
This blog post focuses on the process of loading a class from a Java virtual machine, some of which are referred to in-depth understanding of Java virtual machines. In order to avoid the tedious explanation, in order to let the reader after reading this article can thoroughly understand the class loading process, first
1
U2
Interfaces_count
1
U2
Interfaces
Interfaces_count
U2
Fields_count
1
Field_info
Fields
Fields_count
U2
Methods_count
1
Method_info
Methods
Methods_count
U2
Attribute_count
1
Attribute_info
Attributes
Attributes_count
The version number of the magic number and
JAVA class and object ------ inheritance, java ------ inheritance
Understanding: inheritance can be understood as an object's process of obtaining attributes. If Class A is the parent class of Class B, and
Common Java class libraries-Observer design patterns (Observable class Observer Interface) and observableobserver
Link: http://www.2cto.com/kf/201310/253013.html
To implement the Observer mode, you must rely on the Observable class and Observer interface provided in the java
StaticClassStatic class (Java)
In general, the class cannot be modified using static. If you must use the static modifier class, the static modifier is usually an anonymous internal class.
Create another class in a
Many people may not be familiar with the inner class mentioned in Java. In fact, similar concepts also exist in C ++, that is, nested class (nestedClass). The differences and relationships between the two are compared in the following section. On the surface, an internal class defines another
strings, dates, and numbers are the most commonly used data objects in Java programs, and the creation, modification, formatting, and transformation of these data are incorporated into every corner of the Java program and must be mastered. This section demonstrates the following common entity classes through an instance
Java System-Level classes: System
The Date class _ Calendar class Java. util. Date class is an encapsulation class. If you create an object of this encapsulation class, you can get the system time, and the system time obtained is a Long data type. The data of this
Java class loading sequence and java Loading Sequence
Java class loading sequence
I. Loading Sequence
1. initialize static member variables of the parent class
1.1 static code block
1.2. Common Code Block
1.3 No parameter Constru
First, prefaceThe inner class is also called a parasitic class, which is to put a class inside a class (that is, the upper-level program unit of the inner class is the class) definition, as a member of the outer
To implement the Observer mode, you must rely on the Observable class and Observer interface provided in the java. util package.
Import java. util. *; class House extends Observable {// indicates that the House can be viewed as private float price; // price public House (flo
From: http://klcwt.iteye.com/blog/452834
Create another class in a class called the internal class of the member. The internal class of this Member can be static (modified using the static keyword) or non-static. Static internal classes have various restrictions during definition and use. Therefore, it is not much use
Write a animal class with attributes: Kind; With function: Eat, sleep. Define its sub-class fish PackageZhongqiuzuoye; Public classAnimal {//Properties PrivateString type; PublicString GetType () {returntype; } Public voidsetType (String type) { This. Type =type; } //function Public voideat () {} Public voidsleep () {}} package Zhongqiuzuoye; public
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.