This week, I learned a lot about inheritance, and I know more about it than I did last week. During this writing process, it is found that the prompt statement inside the For loop will appear two times at run time, and the program will make an error. i++ in the loop when the program runs normally, if you put in the For statement inside the program error. Hesheyu after trying to obtain the above results, but do not know the principle inside.
Subclasses inherit all the methods of the parent class, and new methods are added to the subclass, and each subclass can have at most one parent class, and the parent class cannot access the methods in the child class. A variable defined with a subclass can be assigned to a variable that is defined with the parent class, and vice versa. You can define a constant by final, and the object must be assigned a value. A variable defined by private can only be used in the same class, a variable or method defined by public can be used by all classes, and variables defined by protected can be used in the same package. Casts allow you to convert the type of the parent class to the type of the child class. In the parent class, if the abstract method is defined, the parent class must also be decorated with an abstract, and if the child class defines all the abstract methods in the parent class, the subclass may not be an abstract class. Conversely, subclasses are abstract classes. An abstract class can contain specific data and methods, or it can contain no abstract methods. By using a method name in a super.+ parent class in a subclass, you can call the value in the parent class by using the Super override method. A generic array can be defined by ArrayList, regardless of the size of the array. The contents of this chapter will be digested again.
201671010114 2016-2017-2 "Java Programming" Fifth Week study summary