1. Exception Classes In JAVA, except for the RunTimeException class, all exceptions must be caught or thrown.
The above is the essence of Java basic knowledge summary, I hope you master flexible use, learn more, more questions, more Java basic knowledge in the expansion of victory.
2. Class embedding
(1) A class can be embedded in another class, but not in an interface.
(2) In static method or other methods, can not directly create the inner class object, must be obtained by means.
There are two approaches:
class A {
class B {}
B getB() {
B b = new B();
return b;
}
}
static void m() {
A a = new A();
A.B ab = a.getB(); // or a.bab = a.new B();
}
(3) A class inherits an inner class of another class because superclasses are inner classes and the constructor of inner classes is not automatic
The constructor of the superclass needs to be explicitly called in the subclass constructor.
In cases of:
class C extends A.B {
C() {
new A().super(); // Call the inner class constructor.
}
}
The constructor can also be written like this:
C(A a) {
a.super();
} // Use this constructor to create an object, say C C = new C(a); A is the object of A.
(1) The interface is embedded in the class, can use the private modifier. At this point, the interface can only be implemented in the class it belongs to, other classes do not
Can access.
(2) The embedded interface must be public.
4. Multiple inheritance (1) a class inherits a class and an interface, so the class must be written first, the interface is written after, the interface between the use of a
No space.
(2) Multiple inheritance between interfaces. Note the use of the extends keyword.
(3) although a class only implements an interface, but not only to implement all the methods of the interface, but also to implement the interface
Methods of an inherited interface, all methods of which must be implemented in a class.
(1) All data in an interface is static and final, i.e., static constants. Although you can use these two keywords
, but the constant must be assigned an initial value.
(2) The methods in the interface are public. In the implementation interface class, the implementation method must be able to public keyword.
(3) If you use public to modify the interface, the interface must be the same as the file name.
Java Learning exchange group 282711949: a programmer learning platform to share with you, let you accumulate experience in practice master principle. The main direction is JAVA engineers. If you want to get a high salary, want to break through the bottleneck, want to compete with others to get an advantage, want to enter BAT but worry about the interview, you can add my Java learning exchange group: 282711949.
Note: Add group requirement
1. I majored in Java in college, but I was frustrated in the interview after graduation and could not find a suitable job
2. I have been in the company for a long time and now I am comfortable, but I hit a wall in the interview when I change my job. Need to study in a short time, job-hopping to get a high salary
3. After attending the offline training, I have not mastered the knowledge deeply enough, and it is difficult to find employment. I want to further my study
4, already in the Java related departments work on the job, on their own career planning is not clear, dawdle
5, have a certain C language foundation, contact with Java development, want to change careers
Do not disturb the trumpet, do not like to add
The following is the learning route map to share, if you need to save their own: