201621123086 Java Programming 9th Week of study summary

Source: Internet
Author: User

1. This week study summary 1.1 summarizes the set and generic related content in the way you like (mind map or other).
    • One of the primary purposes of generics is to specify what type of object the container holds, and the compiler guarantees the correctness of the type.
    • Tuple, which is a single object in which a set of objects is packaged directly and stored in it.
    • Generics can also be applied to a method, and it has no relation to whether the class in which it is a generic type exists. The method can be changed independently of the class.
    • Generics can also be applied to inner classes as well as anonymous inner classes.
    • Java generics are implemented using erase, which means that when generics are used, any specific type information is erased. We can use it extends to declare a specific type, and then we can safely invoke a method of a type parameter in a method of a generic class.
    • Based on the above features, we only need to use generics when we need the code to work across multiple types.
    • The downside of erasing is that transformations, instancof actions, and expressions in this class are new not valid.
    • Wildcard: <? extends OBJ> with <? super OBJ> But this does not mean that the parameter type can be transformed upward, only that the parameter type has at least the declared type, and the compiler will also directly deny calls to methods that involve wildcards in the argument list.
2. Written assignment 1. The deletion of the specified element in list (topic set) 1.1 Experimental summary. and answer: List at least 2 ways to delete elements in the list.
    • We can detach the string by putting the text in Scanner and calling the next() method
      1. Use List.remove() the method to delete the element to while(list.contains(str)) determine whether the deletion is completely
      1. Use iterator.next() to traverse, str.equals(str) judge elements, and use iterator.remove() to delete elements
2. Count the number of words in the text and sort by the number of occurrences (title of the topic) 2.1 Pseudo-code (not copy code, otherwise deducted)
while()    if(当字符串为!!!!!!)        停止循环    if(字符串在map中不存在)        将字符串存入并设置其value为1    if(存在)        将其value+1并存入调用Collections.sort并编写内部类    value不相同        返回value差值    如果value相同        返回key值差值foreach     输出
2.2 Experimental Summary
    • The point of sorting this problem is to create a new list and place each entry in the map into the list and sort it instead of manipulating the original map. When I finished the problem, I output the original map after I finished the sequence, causing the error. After the teacher corrected the understanding of the implementation of the method of sorting.
3. Inverted index (topic set title) 3.1 Your code run results

201621123086 Java Programming 9th Week of study summary

Related Article

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.