:---------------Characteristics:The function name is the same as the class nameDo not define return value typesThere is no specific return value, and the object is definitely returned after creation.If the class does not have a constructor defined, the JVM allocates an empty construct.If the class defines a constructor, there is no empty construct.Role:Initializes the object.Attention:The characteristics of the default constructor.Multiple constructor
, Feng small Java object-oriented programming thoughtObject-oriented three features: encapsulation, inheritance, polymorphismPackaging:Syntax: Property privatization (private), providing a way to provide relative get/set to access (public),The judgment of the business logic
, dependency inversion principle)
(2) Pattern and Design pattern (3) Example of design patternIV) Exercise 1 using TDD to design the complex to implement the plural class.2. Experiment report to count your PSPTime
Steps
Time Consuming
percentage
Demand analysis
20 minutes
13.3%
Design
About 10 minutes.
6.67%
Code implementation
1 hours 30 minutes or so
60%
Test
30
Person {private int age;//set Private member variable (property variable can only be set to private, local variable not) private String name;public void setage (int a) {//External provisioning member The method of the variable if (a This keyword:function: Used to distinguish between a member variable with the same name and a local variable (this. Member variable)Example: Judging if you are a peerclass Person {private int age;private String name;public int getage () {return age;} public void Set
understand the input and output, the legitimacy of identifiers, the definition of variables, and some of the same knowledge of C language, and so on, although not fully mastered, But also better than before, of course, mainly from the above examples to learn the loop control structure, the use of large numeric classes, one-dimensional arrays and multi-dimensional arrays and the use of irregular arrays, these programs for me or now fully understand still a little difficult, but I try to find inf
(list of references)
Anonymous inner class anonymous inner class does not have a class name, cannot have abstract and static properties, and cannot derive subclasses. The definition format for anonymous inner classes is:new Parent type name (list) {class Body}A sample is easier to understand:Abstract class ClassA {int data;public ClassA (int i) {data = i;} public abstract void Method (); public class ClassB {public static void main (string[] args) {ClassA a = new ClassA (3) {public void me
In object-oriented programming, there can be no further concept of the first step or the second step. "Objects and Classes""Relationships between classes and objects"A> Association Relationshipb> Inheritance Relationship (general and special)c> Aggregation Relationship (whole and part)d> Realization Relationship"Java a
Feedback on issues with the 2017 object-oriented Programming (JAVA) section on nine-week learning summary1. Blog not written by: Gao Shuping Gao Junmei Fong Mau Wang Ruiqiang Zong Peng Li Xianglong Ma Lun Mitch Mao Provencale--The number of students who do not submit the blog in time is on the rise, please think about
, dependency inversion principle)
-we see that the code conforms to the OCP principle by adding a layer of abstraction. Code has a good extensibility, maintainability, the price is more code, inefficient.Design patterns beginners are prone to overuse them, leading to over-design, that is to say, complying with dry and OCP is certainly good, but will appear yagni (you aren ' t gonna need it and you won't need it) issues.The dry principle and the Yagni principle are not fully compatible. The
the collectionJdbc1. Load driver build connection write SQL Execute SQL get result close resource2.class.forname ("SQLServerDriver")Connection conn = drivermanager.getconnectionString sql = "";Statement stmt = Conn.createstatement ()Stmt.executeupdate (SQL)///delete/change executeQuery (SQL)//query3.PreparedStatement Statement Difference1. The former generally requires the presence of placeholders (? )2. The former requires the data to be populated with the pstmt.setxxx () the table below start
internal access, the lowest access level4). Default: Public only for classes in the same packageTwo principles of Encapsulation (approximate):1. Hide as many things as possible and provide a simple interface to the outside.The higher the system's package, the higher its relative independence, and the more convenient it is to use.2. Hide all the attributesIf a property is allowed to be accessed by the outside world, provide a public way to access the propertyWhy not define the volume property as
9.1 polymorphicIn biology, it means that a creature or species can have many different forms or stages;In OOP, polymorphism refers to the ability of an object to have multiple forms.Polymorphism can be said to be the essence of object-oriented programming. One of the reasons why a polymorphic concept is introduced in
#写在前面Following an OOP object-oriented programming of the Russian Block project implementation process, OOP object-oriented programming of the Java game, in fact, writing is very simple,
and set methods, you can invoke the properties and methods in the "partial" class. When new creates an object, it first allocates memory for object properties and initialization blocks, and performs default initialization. If there is a parent class, first allocate memory and perform initialization for the parent class object and initialization block. The initi
subclasses share the code of the parent class, improving the reusability of the code, and later extending and maintaining the code, simply by adding the corresponding subclass.Other points of knowledge related to:Super Keyword: An object that represents the parent class, invokes the properties of the parent class,Methods, construction methods.Abstract keyword: abstraction, adornment class, adornment method.Static keyword: statically, decorated proper
convert the parent class to a subclass type by casting the type, and those members become visible, what happens when the conversion occurs?A class in the construction of the time, the first of its various levels of the parent class are constructed, the family is to Qi Qi whole. Write a test example here to see if you can get the parent reference.It appears that you cannot get a reference to the parent class instance.Classes that must be inherited: abstract classesClasses that cannot be inherite
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.