201671010115 2016-2017-2 "Java program design" Eighth Week learning experience

Source: Internet
Author: User

This week is still the sixth chapter of interfaces, lambda expressions, and inner classes. For interfaces with a deeper understanding of the two examples in the textbook content (ordering of strings, callbacks), for string ordering, we have only learned to use string arrays to achieve sorting operations. Since we learned the interface, we can sort a string array by the comparable interface, use the String.CompareTo method to sort by dictionary order, and also through the java.util.* The comparator interface inside the package implements the string sort by length operation. This is the second version of the Arrays.sort method when we sort the strings in ascending order of length. For callbacks, the timer needs to know which method to call, and the class that the passed object belongs to implements the ActionListener interface of the Java.awt.event package.

Lambda expression is a new breakthrough in the Java language in recent years, it optimizes the program, is a transitive code block, can be executed one to many times. Its syntax is (arguments)->body. The two examples above can be optimized with lambda expressions to reduce the amount of code.

Also learned the inner class, which is mainly used for event processing, with local inner class, anonymous inner class, static inner class. Local inner classes can access local variables in the perimeter scope. There are lambda expressions, anonymous inner classes, in addition to the traditional methods when processing the comparer.

There are some problems with the operation of the file, like writing a file.

201671010115 2016-2017-2 "Java program design" Eighth Week learning experience

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.