Article From:https://www.cnblogs.com/zhouyajie/p/9059241.html

20172308 2017-2018-2″ Java programming “Tenth weeks learning summary

the summary of the content of the teaching material

1. set:

a.Definition: an object, similar to saving other objects’ repository (and providing services such as addition, deletion, etc.)

b.Isomorphism: the types of objects that are saved in a collection are all the same
Isomerism: a collection can save various types of objects

c.Features: the basic data structure of a saved object can be implemented by various technologies, such as interfaces.

2. data structure”

a.Dynamic representation: implemented by “chain”, using object reference as the link between objects.
Advantages: compared with arrays, the required storage space must be fixed in advance. The dynamic representation of data structure can be increased and contracted according to needs.

b.Dynamic structure:

c.Linear data structure
(1)Queue: similar to the list, but the way of access is FIFO.
(2)Stack: similar to queue, but the way of access is “last in first out”.

d.Nonlinear data structure
(1)Tree: a root node
Two fork tree: each node can not have more than two sub nodes.

(2)Figure: there is no initial entry point similar to the root node.
There can be one way or two directions

3. generics”

a.Definition: the type of object managed by a set is determined when the collection object is instantiated.

b.If you do not specify the type of object that may be stored in the collection when it is set up, it is defaults to the object type, that is, the collection can hold any type of object.

problems and solutions in textbook learning

  • Question 1: the book says, “one of the important parts of a collection is that a collection can be implemented in a variety of ways, that is, the underlying data of the object can be implemented in a variety of techniques”, and how to understand it?

  • Problem 1 solution process: with Baidu’s data and Book Tips, it is probably understood that the Java set can not store the basic data types and only store the reference of the object. Different types of collections can be manipulate with corresponding data types.

【Reference data]
ZhuMin_ChosenOneBlogs
guanglihuanA column

  • Question 2: the book says, “the collection is an object”, and I remember the teacher said in class that it is a kind.

  • Problem 2 resolution process: some data from Baidu are called “collection class”.
    Collection classes are referenced by objects rather than objects themselves. For the convenience of expression, we call objects in collections the reference of objects in collections.
    There are 3 main collection types: set (set), list (list) and map (mapping).
    It’s not surprising that collections are objects.

【Reference data]
Baidu Encyclopedia
TonyWA column

  • Question 3: as mentioned in the book, MagazineNode is an internal class, so it is reasonable to declare the data in the internal class as public, so what is the internal class? Why don’t you put it outside? When do you use the internal class?

  • Problem 3 the process of solving:
    a.Definition: nested classes. In object oriented programming, you can define another class within a class.

b.Advantage:

  • (1). An internal class object can access the implementation of its object, including private data.
  • (2). The inner class is not seen by other classes of the same package, and has good encapsulation.
  • (3). The use of internal classes can be very convenient to write programs (emmm, I also think so, do not declare to call a class).

c.Why an internal class is required: an internal class method can access the scoped data defined by that class, including private data.
The internal class can be hidden from the other classes in the same packet, and the general non – internal class is not allowed to have private and protected rights, but the internal class can be able to implement multiple inheritance

d.The most attractive reason for the use of internal classes is:
  Each internal class can inherit independently from one (Interface) implementation, so no matter whether the peripheral class has inherited a certain (Interface) implementation, there is no impact on the internal class.
As we all know, Java can only inherit one class. Its multiple inheritance is implemented by interface before we learn the internal class. But using interfaces is sometimes a lot of inconvenience.
For example, if we implement an interface, we must implement all the methods in it. And the internal class is different. It can enable our class to inherit multiple concrete classes or abstract classes.

【Reference data]
tony~Blogger
Baidu Encyclopedia


In the program, write three addDVD methods, according to the reason should output different content, but the result only output third add content, check the add method of writing, it should be no error, and then guess that the toString should be written wrong, the code such as:

The original collection is an array object and then traverses the elements in the array through the for loop and prints it, but the change in the loop will be wrong after the change.
After changing the toString method, the code is as follows:

By printing the elements of each node through the linked list, the problem is solved.

code trusteeship

the summary of the wrong questions in last week’s examination

  • Wrong question 1:

  • Error analysis 1: this method compares each character in string a with char b until I reach the length of string a. 1 is added to each matching return value.

  • Problem 2:

  • Error analysis 2: this method recursively calls itself, n is half of its original value. If n starts from 16, the second calls have n = 8, third have n = 4, fourth have n = 2, fifth and the last call has n = 1. If n starts from 32, it will increaseAdd an extra call. If we double again, it will only add a recursive call. This is a log2 (n) behavior.

  • Problem 3:

  • Error 3 Analysis: for simplicity, mathematics usually defines functions recursively. This question makes me suspect that other items have the right possibility, but in the final analysis, the function and meaning of recursion are not really understood.

  • Problem 4:

  • Error 4 Analysis: if you call x&lt, 0, the original method will lead to infinite recursion, but if you use any x&gt, = 0, you can work normally. For the new basic case, if you use any parameter &gt, = 1, the method can now work normally, but if the parameter &lt1, it leads to infinite recursion. So sum (0) is different from that before. The reason for this mistake is that there is no serious analysis of recursive code. In two cases, the conditions for recursion are different.

  • Problem 5:

  • Problem 5 parsing: recursive definition does not contain the basic situation, so all int values list will be infinitely long! First of all, the title of this question is not understood, the underline behind list does not know what it means, it can not see where there is a recursion shadow. And there’s no Baidu.

  • Problem 6:

  • Error 6 Analysis: recursion and iteration are all repeated forms. The use of recursion or iteration is a style, flavor, sometimes efficiency, and sometimes convenience. But they are equivalent in computation – each one can be replaced by another. Because the book only mentioned that recursion can be replaced by loops.It is said that the two can be interchangeable, and there is no affirmative argument on Baidu, so they have chosen the wrong way, which reflects that their minds are not divergent enough.

  • Problem 7:

  • Error analysis 7: add method applies to ints greater than or equal to zero; but if B is less than 0, it fails. Like the previous question, you can’t read the title, do not know what the meaning of the question mark is, maybe Baidu will do it, but the time is limited.

  • Problem 8:

  • Problem 8 parsing: multiplication is only the addition of repetition. This method is just a repeat of the addition of a, B multiplied by. As long as a and B are nonnegative, this method is fine. Keep up with the same problem.

pairing and mutual evaluation

  • What is worth learning or problems in the blog:
    • The layout of Hou Zeyang’s blog is neat and the interface is beautiful.
    • The summary of the problems is well done
    • The doubts on books always try to solve it. The spirit of exploration is worth learning.
  • What is worth learning or problems in the code:
    • The writing of programming can always find a way to solve it
  • This week’s pair of pair learning
    • 20172302
    • Pair learning content
      • The thirteenth chapter: the collection

learning progress bar”

Number of lines of code (New / cumulative) Blogs (New / cumulative) Learning time (New / cumulative) Important growth
target 5000That’s ok 30piece 400hour
First week 309/309 1/1 20/20
Second weeks 269/578 1/2 18/38
Third weeks 236/776 1/3 22/60
The fourth week 507/1283 2/5 30/90
Fifth weeks 631/1914 1/6 30/120
Sixth weeks 529/2443 1/7 25/145
Seventh weeks 515/2958 1/8 25/170
Eighth weeks 1128/4086 2/10 50/220
Ninth weeks 1241/5327 1/11 15/235
Tenth weeks 1852/7179 1/12 10/245

reference”

  • JavaLearning notes (Eighth Edition)
  • 《JavaLearning notes (Eighth Edition) learning guidance
  • Blue Mo class class
  • Life one
    ZhuMin_ChosenOneBlogs
    guanglihuanA column
    Baidu Encyclopedia
    TonyWA column
    tony~Blogger
    Baidu Encyclopedia

Similar Posts:

Leave a Reply

Your email address will not be published. Required fields are marked *