# 1. This week's learning summary

## 1.1 Object oriented learning is over , Please use mind map , To encapsulate 、 Inherit 、 Draw a mind map for the core concept , Make a summary of the object-oriented thinking .

notes 1： No more keywords and content , But the connection between concepts needs to be clear , Content covers the core content of object-oriented .

notes 2： Less color 、 The connection should not be complicated , If necessary, explain it on the line .

## 1.2 Optional ： Summarize other lessons in the usual way .

Reference material :

XMind

# 2. Written work

## 1.clone Method

### 1.1 Object Object clone The way is to be protected modification , Override... In a custom class clone What should we pay attention to when we do this ？

 answer ： Only within this class or with Object Use in the same package , It can't be used in other classes ; If you will protected Switch to public, Will narrow its limitations .

### 1.2 Design your own class , What kind of methods are generally used protected To embellish ？ With homework Shape For example, .

 answer ： By protected The method of modification can be seen in this package , It is also visible to subclasses of the class where the method is located , But not accessible by external packages . stay Shape Abstract classes defined in Shape Abstract methods defined in getPerimeter and getArea Both can be used. protected To modify , To subclass Rectangle and Circle Is visible .

### 1.3 stay test1 Write simple Employee class , stay test2 Create a new one in the package TestProtected class , And in main Try calling test1 In bag Employee Of clone Method to clone a new object , The success of ? Why? ？

 answer ： Can't succeed , because Employee Classes and TestProtected Class is not in the same package . Can be Employee use public modification , Make other classes accessible .

## 2. Use anonymous classes and Lambda Expression rewriting problem set object oriented 2- Advanced - The topic of polymorphic interface inner class 5-2

Just paste the key code and running results , Don't make the picture too big .

Comparator<PersonSortable2> NameComparator = new Comparator<PersonSortable2>() {
public int compare(PersonSortable2 obj1,PersonSortable2 obj2) {
if (obj1.getName() .compareTo(obj2.getName()) > 0)
return 1;
else if (obj1.getName().compareTo(obj2.getName()) < 0)
return -1;
else
return 0;
}
};
Comparator<PersonSortable2> AgeComparator = new Comparator<PersonSortable2>() {
public int compare(PersonSortable2 obj1,PersonSortable2 obj2) {
if (obj1.getAge() > obj2.getAge())
return 1;
else if (obj1.getAge() < obj2.getAge())
return -1;
else
return 0;
}
};


Lambda expression

Comparator<PersonSortable2> NameComparator=(o1,o2)-> o1.getName().compareTo(o2.getName());
Comparator<PersonSortable2> AgeComparator=(o1,o2)-> o1.getAge()-o2.getAge();


## 3. Analyze the following code , answer shapeComparator The object pointed to is related to Comparator What does the interface have to do with ？

Comparator<Shape> shapeComparator = new Comparator<Shape>() {
@Override
public int compare(Shape o1, Shape o2) {
}
};


 answer ： Write with anonymous inner class methods , send shapeComparator Realization Comparator Interface , It can be used Arrays.sort() Methods the sorting .

## 4.GUI Event handling in

### 4.1 Write the most important keywords in the event processing model .

 answer ： Event source — Event object — Event listener

### 4.2 Use code and comments , Prove that you understand the event handling model .

public class EventObject implements java.io.Serializable {
protected transient Object source;
public EventObject(Object source);
public Object getSource();//getSource Get the event source
public String toString();
}
public class MainGUI {
public static void main(String[] args) {
JFrame f = new JFrame("Test");// Create an event template Test
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);// Set the user to initiate... On this form "close" Default action when
JButton b = new JButton("Press Me!");// Here's a button event source
b.addActionListener(new ButtonHandler());// Next you need to use the event listener , So register here first
f.setSize(200, 100);
f.setVisible(true);
}
private static class ButtonHandler implements
ActionListener{// Monitor
public void actionPerformed(ActionEvent e) {
System.out.println("Action occurred");
System.out.println(e.getSource());// Get the event source
}
}
}


## 5. Pair programming ： Object oriented design ( Big homework 2- It's very important , Hang in the air -2)

Continue to improve last week's project assignment . The assessment points are as follows ：

### 5.3 Compared with last week , What are the major changes to the project ？

Reference material :

Pair programming reference

Use Processon drawing

video - Use Netbeans To write GUI

important ：Swing Experimental references

JTable usage , Used to render table data

Swing Related articles

# 3. Code submission records and PTA Summary of the experiment

Topic collection ：jmu-Java-04- object-oriented 2- Advanced - Polymorphic interface inner class

## 3.2. PTA experiment

function ( Choose to do ：4-1)、 Programming (5-3, 5-4)

There must be a summary of the experiment

• Use anonymous classes and Lambda Expressions simplify code , It can be written directly in the sort statement .
• Pay attention to the judgment of empty stack and full stack .
• Static inner class , Defined in class , In any way , use static Definition . Mainly in methods of external classes , Create inner class objects , Use properties of inner classes , Static inner classes can only access static members of outer classes .

1. 20145213《Java Programming 》 Learning summary week nine

20145213<Java Programming > Learning summary week nine Summary of textbook study " The May Day " The holidays go too fast , It's like a tornado . Not a little bit on guard , Just like Java Blogs are full of . In this festival of universal celebration , root ...

2. 20145213《Java Programming 》 Second week learning summary

20145213<Java Programming > Second week learning summary Summary of the learning content of the textbook The task given by Mr. Lou this week is to study the third chapter of the textbook -- Basic grammar . Actually, I think it's quite relaxed , Because I'm opening heavy books , A familiar breath came to my face , ...

3. 20145213《Java Programming 》 Study summary of the first week

20145213<Java Programming > Study summary of the first week Summary of the learning content of the textbook Looking forward to a winter vacation , Finally, I saw the mysterious teacher Lou and his Java course . Although it's not really a meeting , It's reasonable that there are countless people in the world without victory , Dan Lou ...

4. 21045308 Liu Haoyang 《Java Programming 》 Learning summary week nine

21045308 Liu Haoyang <Java Programming > Learning summary week nine Summary of the learning content of the textbook The first 16 Chapter Consolidate databases 16.1 JDBC introduction 16.1.1 JDBC brief introduction The database itself is a stand-alone application Write ...

5. 20145330 Sun Wenxin 《Java Programming 》 Study summary of the first week

20145330 Sun Wenxin <Java Programming > Study summary of the first week Summary of the learning content of the textbook It's impossible to get such a thick book without pressure at first , From the beginning, I feel strange and can't enter the state , Just a little bit of anxiety . So he ...

6. 20145337 《Java Programming 》 Learning summary week nine

20145337 <Java Programming > Learning summary week nine Summary of the learning content of the textbook The database itself is a stand-alone application Writing application program is to exchange instructions to database by using communication protocol , To add, delete and search data JDBC Sure ...

7. 20145337 《Java Programming 》 Second week learning summary

20145337 <Java Programming > Second week learning summary Summary of the learning content of the textbook Java It can be divided into basic type and class type : The basic types are integers (short.int.long). byte (byte). Floating point numbers (float ...

8. 20145218《Java Programming 》 Study summary of the first week

20145218 <Java Programming > Study summary of the first week Summary of the learning content of the textbook I saw it this afternoon Java Learning videos , It's very novel , I thought before Java It's hard and boring to learn , But through the study of the first chapter, I feel that if I can ...

9. 《Java Programming 》 Learning summary week nine

20145224 <Java Programming > Learning summary week nine Chapter 16 Consolidate databases JDBC introduction · The database itself is a stand-alone application · Writing application program is to exchange instructions to database by using communication protocol , In order to do the data analysis ...

10. 《Java Programming 》 Second week learning summary

20145224 Chen Haowen <Java Programming > Second week learning summary Summary of the learning content of the textbook One . type . Variables and operators 1. type Integers : It can be subdivided into short Integers ( Occupy 2 byte ),int Integers ( Occupy 4 byte ),long ...

## Random recommendation

1. 20145334 《Java Programming 》 The first 10 Weekly learning summary

20145334 <Java Programming > The first 10 Weekly learning summary Summary of the learning content of the textbook One . Network programming • Network programming for many beginners , It's a programming skill I'm looking forward to , But many beginners can't get in for a long time ...

2. turn ： Use vs2013 open VS2015 The solution of engineering documents ( For most vs Lower version opens higher version )

http://www.cnblogs.com/WayneLiu/p/5060277.html Preface : Before I remounted the system, I used vs2015( A little bit *), Due to the use 2015 It's so different in class , Cause I want to be in the other same ...

3. python And character set encoding

A blog that makes it clear :http://www.cnblogs.com/huxi/archive/2010/12/05/1897271.html Take the Chinese in the above blog as an example , Chinese characters GBK Encoding is baba, UNIC ...

4. Nginx Configure domain name forwarding instance

domain name :cps.45wan.com   Alicloud host :123.35.9.12 45wan Not recorded in alicloud 67wan It has been put on record in Alibaba cloud Alicloud host ( If 123.35.9.12) On the original nginx To configure : ...

5. hibernate：There is a cycle in the hierarchy! Cause a dead loop solution

Here's the exception : I searched the Internet for :There is a cycle in the hierarchy!, I know it's because of the dead cycle ! It's been a long time , No success , The backstage has to consult the boss , The boss said it was because he was using JSON ...

6. Release Rafy .NET Standard edition Nuget package

Mid year last year ,Rafy The source code of the framework already supports Net Standard 2.0 edition . Its open source code has also been uploaded to Github in :https://github.com/zgynhqf/rafy/tree/ ...

7. [ National Team ] Crash Our civilized world

Description Given a tree $$n$$ A dot tree , For each point $$i$$ seek $$S(i)=\sum\limits_{j=1}^n \operatorname{dist(i,j)}^k$$ .\ ...

8. Online tools

Explore online vulnerability for servers and IoT devices : https://www.shodan.com get dumped leaked ...

9. Python introduction modular

module modular atestmodule.py #!/usr/bin/env python3 # -*- coding: utf-8 -*- 'a test module' def addFunc( ...

10. SpringBoot Custom error page

(1) With a template engine , for example 404 error , Will be in thymeleaf Of templates Of error Look for 404.html, If you can't find it, look for it again 4xx.html * all 4 If the error status code at the beginning cannot find a specific ht ...