1.Java conventions
Java Conventions 1, class name Interface name One word uppercase, multiple words each word first letter uppercase 2, method name and variable name a word all lowercase, multiple words from the second word capitalized advice: If you can use English as much as possible in English, I can't. write in Hanyu Pinyin code 1, curly braces in pairs, the opening brace at the end of the line code, the closing brace at the bottom of the line code, and theLine code is aligned with 2, the left curly brace preceded by a space 3, the middle side of the statement will need to add space 4, statement block or method in the middle of empty lines
2. Object-oriented features
The characteristics of object-oriented thinking * A: A thought that is more in line with our thought habits * B: Can simplify complex things * C: Turn us from the executor to the conductor * The role has been transformed.
* A: Object-oriented development * is constantly creating objects, using objects, directing objects to do things. * B: Object-oriented design * is actually the relationship between managing and maintaining objects. * C: Object-oriented feature * encapsulation (encapsulation )* Inheritance (inheritance )* Polymorphism (polymorphism)
3. Classes, objects
*A: What Are we learning to program for?*In order to describe our daily life in the language of learning*B: How do we describe real world things*A property is a descriptive message of the thing (a noun on a thing).*behavior is what the thing can do (verbs in things)*The most basic unit in C:java is the class, and the same is true in Java, which describes things in class .*a member variable is a property of a thing*A member method is the act of something.*D: Defining a class is actually a member of the definition class (member variables and member methods)*A: The member variable is the same as the previously defined variable, except that the position has changed. In the class, outside of the method. *B: The member method is the same as the previously defined method, except that static is removed and the function of static is explained in detail later. *E: Concepts of classes and objects*A: Class: is a set of related properties and behaviors*B: Object: Is the concrete embodiment of this kind of thing*C: For example:*class Students* An object specific to a student is an object
4. Case presentation
*A: Student Affairs*B: Student class*C: Case Demo*Properties: Name, age, gender*behavior: study, Sleep*classStudent {String name; intAge ; Chargender; Public voidStudy () {SYSTEM.OUT.PRINTLN (name+ "In bed"); } Public voidsleep () {System.out.println (name+ "in learning"); } }
**Property: Brand Price*behavior: Call, Send Message (sendMessage) play games (PlayGame) classPhone {String brand; intPrice ; Charcolor; Public voidCall () {System.out.println (Brand+ "Call"); } Public voidSendMessage () {System.out.println (Brand+ "Send SMS"); } Public voidPlayGame () {System.out.println ("Playing games"); } }
5. The difference between a member variable and a local variable
* A: The position in the class is different * member Variable: Outside of the method in the class * Local variables: In a method definition or on a method declaration (parameter) * B: in memory, in different places * * local variable: in stack memory (local variable belongs to method, method into stack memory) * C: Life cycle is different * member Variable: As the object is created, disappears as the object disappears * * D: Different initialization values * member Variable: default initialization value * * note: * Local variable names can be the same as member variable names, using the nearest principle when used in methods.
6. How the form parameter or return value of a method is called when it is a class name
* A: The parameter of the method is the class name
* If you see the form parameter of a method is a class type (reference type), what you need here is the object of that class.
* B: The return value of the method is the class name
* If you see the return value of a method is the class name, this is actually the class object that is returned
7. Overview and application of anonymous objects
* A: What is an anonymous object ** B: Anonymous object Application scenario * A: Call method, only call once. * So what is the benefit of this anonymous invocation? * Save Code * Note: It is not appropriate to call multiple times. The anonymous object call is complete garbage. Can be reclaimed by the garbage collector. * B: Anonymous objects can be passed as actual parameters
8. Overview of Encapsulation
* A: Package overview * refers to the properties and implementation details of hidden objects, providing public access only to the outside. * B: Package Benefits * Hide implementation Details, provide public access * Improve code reusability * improve security. * C: Packaging principles * will not need to provide external content is hidden. * Hide properties and provide public methods for accessing them.
Overview and features of 9.private keywords
* A: Questions about age of human assignment * b:private keyword features * A: is a permission modifier (smallest) * B: Can modify member variables and member methods * C: The member modified by it can only be accessed in this class * C: Case Demo * Package and private application: * A: The member variable is modified with private * B: Improve the corresponding getxxx ()----obtained, and setxxx ()---- modified, with parameters, method * Private is just a form of encapsulation, cannot say encapsulation is private
Ten. This keyword features
* method is called by which object, this represents that object,
* Can be used to distinguish between member variables and local variable names.
Classes, objects (Java Basics VI)