Study Number: 201621123032 Java programming 9th Week of study Summary (

Source: Internet
Author: User

1: Study Summary of the Week 1.1: Summarize the set and generic related content in the way you like (mind map or other)

2: The deletion of the specified element in the written job 2.1:list (title of the topic) 2.1.1: Experimental summary. and answer: List at least 2 ways to delete elements in the list.

First build a list List<String> str =new ArrayList() , put the elements into the list in turn. Use iterators Iterator<String> it = list.iterator() to compare, delete, and then click once.

Methods for deleting elements:
1: Use traditional for loop traversal to find a match to delete it. However, by deleting an element in this way, the subsequent element is automatically moved forward, resulting in less traversal of an element the next time it is traversed. If two elements are adjacent, the subsequent element is not deleted. Workaround: After entering judgment, I minus 1.
2: Method List.iterator () does not have this problem.
3: You can create a new list without deleting it into the list.

2.2: Count the number of words in the text and sort by the number of occurrences (topic set) 2.2.1: Pseudo-code
new一个HashMap,名为dict;while进行循环判断{   if  输入的单词eequal "!!!!!";        break;   else       if    dict没有相应的key          dict加入新元素,value的值=1;      else                        dict的value的值加1;        }new 一个ArrayList的对象list;调用Collection.sort方法,重写compare方法,进行排序。for循环,输出前10个。
2.2.2: Experimental Summary

1: The subject should first create a hashmap, initially did not understand test instructions, do not know what to use as the key value.
2: When adding hashmap words, to judge, if there is a corresponding value plus 1, at first do not know how to add 1 value.
3: The subsequent sorting is difficult, because Collections.sort only sorts the list, so you should first convert the HashMap to list, and then override the Compare method.

2.3: Inverted index (title): The topic is more difficult, do not come out does not matter. But must have own thinking process, must have the submission result. 2.3.1 your code to run the results

The subject is in the classmate's help, write out, oneself at the beginning not to understand what meaning, also have no idea.

2.3.2 Pseudo-code (no copy code, otherwise deducted)
new一个Map对象map; key为单词元素,value为单词所在行数。while进行循环判断{    i++;标记行数;   if  输入的单词eequal "!!!!!";        break;  else      把每行英语单词放入数组 str;   for(数组){      if   map中没有相应的key         new ArrayList的对象line;         line.add(行数i);         map中put入新元素,    else       判断当前行数是否存在,没有就添加到value; 创建迭代器; 遍历输出map; 输入字符串,以空格隔开。  if  不同时存在指定单词   输出found 0 results;  else     求指定单词的交集;     if  交集为0;      输出found 0 results;    else       输出交集和行数;           }}
2.3.3 Experiment Summary

The subject is in the classmate's help, write out, oneself at the beginning not to understand what meaning, also have no idea.
The subject to make multiple judgments, first of all to determine whether the map exists, does not exist to be added to, the existence of the words to determine whether the same value as before, not the same value to be added, initially did not consider a row may have several identical words and error.
Map add complete to judge the intersection is also a difficult point, at first there is no idea, do not know how to achieve. Finally, with the help of others to know the Retainall method to beg.

2.4:stream and Lambda

Write a student class that has the following properties:

private Long id; private String name; private int age; private Gender gender;//枚举类型 private boolean joinsACM; //是否参加过ACM比赛` 创建一集合对象,如List<Student>,内有若干Student对象用于后面的测试。
2.4.1: Writing a search method using traditional methods List<Student> search(Long id, String name, int age, Gender gender, boolean joinsACM), and then call the method to id> a value, name is a value, age> a value, gender to a value, students who have participated in the ACM contest are screened out and put into a new collection. Called in Main, and then outputs the result. (: There is a number, name).

Search method:

Filter into a new collection:

Operation Result:

2.4.2: Use the Stream () in Java8, filter (), collect () to write the code with the same 4.1, and test (to show the test data). When building a test collection, in addition to the normal student object, add some null to the collection, and the method you write should handle the null instead of throwing an exception. (: The school number appears)

Using Stream () in Java8, filter (), Collect ():

Operation Result:

2.5: Generic class: Generalstack---The code of the Generalstack2.5.1:generalstack interface of the set jmu-java-05-collection

2..5.2: What are the benefits of generics compared to the arraylistintegerstack in previous assignments?

The subject of generic type, only define an interface can be based on their own requirements to set the type of the stack, such as the integer, double and car type. Previous job arraylistintegerstack can only operate on elements of type integer and have limitations. Using generics is more flexible and reduces code redundancy.

3:. Code cloud and PTA3.1: Code cloud codes Submission record

3.2:pta the complete picture of the problem set


3.3: Count the amount of code done this week

Week Time Total code Amount new increase in code volume Total Folder Add new Folder
1 114 114 11 11
2 520 50W 16 6
3 1089 569 22 6
5 1425 336 29 7
6 1819 394 31 2
7 2987 1168 54 23
8 5437 2450 79 25
9 5695 258 84 5
10 6680 985 102 18
4: Evaluate how much you understand Java
Dimension of
Grammar Some basic grammar is not a problem, but there are some unskilled grammar, need Baidu
Object-oriented design This aspect is weak, has the basic logic of thinking, in doing the shopping cart big homework often will make mistakes, do not know where to start
Application capabilities The application ability is poor, can complete some simple program
So far code 6680 But there is a small part of the code is not their own, is learning materials, statistics are counted in the time

Study Number: 201621123032 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.