1. Summary of this week's study
2. Written work
Clone method
1.1 Object in theclone
method is modified by protected, what do you need to be aware of when overriding the Clone method in your custom class? Answer: OverwriteThe Clone method first sets the property to public .
1.2 When you design your own class, what kind of method is generally used to modify the protected? Take the job Shape
as an example. , &NB Sp , &NB Sp A: PR Otected modified variables, subclasses can directly access the parent class members or quilt class overrides. In the shape, the amount of abstraction associated with the graph, such as the length and width of the height, can be protected.
1.3 Write a simple Employee
class in the Test1 package, create a new testprotected
class in the Test2 package, And in main, try to invoke the Clone method of the employee in the Test1 package to clone a new object, can it be successful? A : Failure, because the Clone method is protected decorated, and protected is modified only in the subclass and in the same package access.
Overriding a topic with an anonymous class and a lambda expression object-oriented 2-advanced-the problem of the inner class of a polymorphic interface 5-2
Just paste the key code and run the results, the picture is not too large. For:
Analyze the following code to answer shapeComparator
what does the object pointed to have to do with the comparator interface?
New Comparator<shape>() { @Override publicint Compare (Shape O1, shape O2) { // Your code } };
答:这是一个匿名内部类,实现了Comparator接口并且重写了compare方法。
Event handling in the GUI
4.1 Write out the most important keywords in the event-handling model. Answer: event, event source, event listener
4.2 Use code and annotations to prove that you understand the event-handling model. For:
Public classEventObjectImplementsjava.io.Serializable {protected transientObject Source; PublicEventObject (Object source); PublicObject GetSource ();//Get Event Source PublicString toString ();} Public classMaingui { Public Static voidMain (string[] args) {JFrame F=NewJFrame ("Test");//Create an Event templatef.setdefaultcloseoperation (jframe.exit_on_close); JButton b=NewJButton ("Press me!");//Event SourceB.addactionlistener (NewButtonhandler ());//Registering event ListenersF.add (b); F.setsize (200, 100); F.setvisible (true); } Private Static classButtonhandlerImplementsactionlistener{//Listener Public voidactionperformed (ActionEvent e) {System.out.println ("Action occurred"); System.out.println (E.getsource ());//Get Event Source } }}
3. Code submission record on code Cloud and PTA Experiment Summary
Pair programming: Object-oriented design (big job 2-very important, unfinished-2)
Continue to refine last week's project assignments. The assessment points are as follows:
5.1 Try overwriting using the graphical interface.
5.2 Gives a record of the same item on the code cloud for two people.
5.3 What are the major changes to the project compared to last week?
Resources:
Pair programming Reference
Drawing with ProcessOn
Video-writing a GUI with NetBeans
Important: Swing Experimental reference
JTable usage, for rendering tabular data
Swing related articles
3. Code submission record on code Cloud and PTA Experiment Summary
Topic set: jmu-java-04-Object-oriented 2-advanced-polymorphic interface inner class
3.1. Code Cloud codes Submission record
3.2. PTA Experiment
1. Learned to define an interface. 2. Learn how to create a static inner class and its methods inside a class.
201521123088 Java Programming 6th Week of study summary