Study number 20145336 "Java Program Design" 3rd week study summary textbook Learning content Summaryclasses and objects:
Object-oriented: Three major features: encapsulation, inheritance, polymorphism.
Development is to find objects to use, without objects, create a copy of the object. Find objects, build objects, use objects, and maintain the relationships of objects.
Class and object relationships:
Class is the description of the food in the life of the mind. The object is such a thing, a real existence of the individual.
Describe the properties and behavior of an object's things
properties correspond to variables in classes, functions in the corresponding class (methods)
In fact, defining a class is describing things, that is, defining attributes and behaviors, and attributes and behaviors that are common to members in a class (member variables and methods)
The object is specified in the object. Object Members
In a Java document can have more than one class, when the class only need to describe a thing, and do not need to run independently, it is not necessary to write the main function, such as the 84th page of the textbook clothes class there is no main function, it is just to describe things, it is similar to our C language defines a function. But we try not to write multiple classes in a class, if there are multiple classes, there can only be one class before the public, to form a kind of a file habit.
Class type variables point to object entities
A member variable acts on the entire class, and the local variable acts in the function or in the statement. The member variable is in heap memory and exists in memory because the object exists. Local variables exist in the stack memory.
Anonymous object usage: 1, when the method of the object is only electrophoresis once, you can use the anonymous object to complete, so it is easier to write. If multiple member transfers are made to an object, the object must be given a name. 2. Anonymous objects can be passed as actual parameters.
Standard class
Two basic standard classes: Java.util.Scanner and Java.math.BigDecimal ()
Java.util.Scanner
Java.util.Scanner can help you to be lazy.
Java.util.Scanner class: Java.util.Scanner the Nextint () method will look at the standard input, there is no input the next string (separated by a space or newline), some will try to parse it into the int type, the other Nextbyte (), Nextshort () are similar in function. If you get the previous string directly (separated by a space or line break), use Next () and if you want to get the entire line of text entered by the user, use Nextline () (separated by a space or line break), in summary the scanner class greatly simplifies the Java input.
Java.math.BigDecimal ()
One way to create BigDecimal is to use a string, which, when created, will parse the incoming string and perform the next operation with the default precision. BigDecimal provides methods such as plus (), substract (), multiply (), divide (), which can be added, minus, multiplied, and removed, all of which return the bigdecimal representing the result of the operation.
Basic Type Packager
You can use long, Integer, Double, Float, Boolean, Byte, and other classes to package the basic types, which are called Packers, and the main purpose of these tears is to provide object instances as "shells", which are packaged into objects so that you can manipulate the object. You can let the Java primitive Type act like an object.
Array
In Java, an array is an object, not a simple collection of arrays, and once an array is established, its length is fixed.
One-dimensional arrays use an index to access an array element, and a two-dimensional array accesses an array element using two indexes.
In Java, you can use the System.arraycopy () method to replicate an array value, which replicates each index element in its native way, faster than using a loop. In the version above JDK6, there is a more convenient arrays.copyof () method that can help you create a new array. Whether System.arraycopy () or arrays.copyof () is used in an array declared by a class type, a shallow copy is performed.
Object Encapsulation
The purpose of encapsulation is to hide the main object details and manipulate the object as a black box. The user invokes the constructor, but does not know the specifics of the constructor, knows the method, but does not know its flow.
this keyword
This is a reference to the object to which the function belongs, in short, a reference to the object of this class, and we can use this when the object that invokes the function is needed within the function. The This () call can only appear in the first row of the constructor.
Static keyword
A member that is declared static does not have an individual object owned, but belongs to a class. We also use the class name with "." operator, you can obtain a static member. Both in and out of the system.in and system.out that we have been using are static members.
Static members belong to the class, and the class name as a namespace is the most common way to use it. Because static members belong to a class, not an individual object, using this in a static member is a semantic error. There are cases where this is not written, but it implies that the meaning of this is inside, and therefore a compilation error occurs.
When the. class is loaded by the JVM, the static block is executed by default. After JDK5, the import static syntax is added, and you can make fewer words when using static members. We can be lazy by the import, lazy over the problem, pay attention to name conflict issues, some name conflicts, the compiler can be in the following order to
Problems in teaching materials learning and the solving process
The understanding of the class is difficult to understand at first, but it will be understood more thoroughly after combining it with the code.
This study is my first time to use Eclipse to write code, there are many places with the help of students to solve the problem.
The definition of stacks and heaps is not understood, in the video and memory of the teacher in the course of the final understanding of the difference between the two and contact
Problems in code debugging and the resolution process
When you write code, the save file is not in the same package, so it runs always on the previous file, copies the file, and then runs it.
Other (sentiment, thinking, etc., optional)
Drawing a flowchart is a good way to solve a problem. When you write code, you can draw a flowchart and then turn the flowchart into code. When reading the code, you can also convert the code to a flowchart before you understand the flowchart. This conditioning is clear, and will not be a complex code to disrupt their thinking.
Learning progress Bar
|
lines of code (new | /Cumulative)
Blog volume ( | new/cumulative)
Learning time (new/cumulative) |
Important growth |
| Goal |
5000 rows |
30 Articles |
400 hours |
|
| First week |
150/150 |
1/1 |
15/15 |
|
| Second week |
150/400 |
1/2 |
15/30 |
|
| Third week |
150/550 |
1/31 |
20/40 |
|
Resources
- Java Learning Notes (8th Edition)
- Java Learning Note (8th Edition) Learning Guide
- ...
Java Third Week study summary