201621123002 Java programming Nineth Week of study summary

Source: Internet
Author: User
Tags comparable set time

1. This week study summary 1.1 summarizes the set and generic related content in the way you like (mind map or other).

1.2 Choose: Collect code snippets that you think are useful

Functional requirements: Generate a new list object that is greater than 5
List

2. Written work

This job title set集合

1. Deletion of the specified element in list (title of topic) 1.1 Experimental summary. and answer: List at least 2 ways to delete elements in the list.

Experiment Summary: Note that when you call remove to delete an element, the original position automatically complements the next element before it is deleted.

Method One:

publicstaticvoidremove(List<String> list, String str) {        for (Iterator<String> iterator = list.iterator(); iterator.hasNext();) {            String strs = (String) iterator.next();            if (str.equals(str))                iterator.remove();        }    }

Method Two:

    publicstaticvoidremove(List<String> list, String str)    {        for(int i=list.size()-1;i>=0;i--)        {            if(list.get(i).equals(str))                list.remove(i);        }            }
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)

Each line of whitespace is added to the set to get the number
Set is converted to Map,key as a word, value is the number of occurrences
Sort the value of map

2.2 Experimental Summary

Compared to 5-2, this problem is more on the map value of the sort and frequency of statistics, yes or online search

3. Inverted index (problem set)

The subject is more difficult, do not come out does not matter. But must have own thinking process, must have the submission result.

3.1

3.2 pseudocode (Do not copy code, otherwise deduct)

Create TreeMap, where the key type is String,value type ArrayList
Create a ArrayList object T that holds the characters for each line
Looping through words in an article
While is not a "!!!!!"
Reads whole line characters, splits characters
There is no corresponding key in the IF map
Add a word to map and add the value of the current number of rows to value
ELSE
Determines whether the current number of rows already exists in value, and if not, adds the current row count to value
Traversing the contents of the output map
Enter the characters you want to find
If only one character is found
IF The specified word does not exist in the IF map
Output found 0 results
ELSE
Outputs the value of the specified word
ELSE
Splits the character and confirms whether the word is present
If all exists
Ask for Intersection
IF intersection is 0
Output found 0 results
ELSE
Output intersection
The character of the output intersection line number
ELSE
Output found 0 results

3.3 Experimental Summary

Follow the pseudo-code thinking step by step write code, the process is a little smooth, is the PTA can not, so far did not find the reason ...

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;//enum type
Private Boolean JOINSACM; Have you participated in the ACM contest?

Creates a collection object, such as a list

4.1 Writing a search method using traditional methods list


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)


5. Generic type: Generalstack

The Generalstack of jmu-java-05-collection of title set

5.1 Code for Generalstack interface

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

Greatly reduce the amount of code, more flexible, the previous job in the Arraylistintegerstack, it is clear that the object is an integer, if you want to store other types of objects, it is necessary to write an interface, which is very troublesome, the topic using generics will not have this problem.

6. Select: Generic method

The base reference file GenericMain , which is modified on this file.

6.1 Write Method Max, which returns the maximum value of all elements in the list. The elements in the list must implement the comparable interface. The Max method you write should make string max = Max (strlist) run successfully, where strlist is a list

6.2 Optional: The existing user class, whose subclasses are Stuuser, and all implement the comparable interface. Writing method Max1, basic ability with 6.1, make user user = Max1 (stulist), can run successfully, where stulist is List

6.3 Choose: Write int mycompare (t O1, T O2, Comparator C) method, this method can compare two user objects, can also compare two Stuuser objects, the incoming comparator C can be Comparator

3. Code Cloud and PTA

Topic Set: jmu-java-05-Collection

3.1. Code Cloud codes Submission record

In the Code cloud Project, select statistics-commits history-set time period, and then search for and

3.2 PTA Problem set complete situation diagram

Two graphs are required (1. Ranking chart. 2.PTA Submission list diagram)


3.3 Count the amount of code completed this week

The weekly code statistics need to be fused into a single table.

Week Time Total code Amount New Code Volume total number of files number of new files
1 0 0 0 0
2 0 0 0 0
3 0 0 0 0
4 0 0 0 0
5 0 0 0 0
6 1707 1707 31 31
7 2093 386 36 5
8 2910 817 42 6
9 3153 243 47 5
10 3595 442 53 6
4. Assess how much you understand Java

Try to evaluate how much you understand Java from the following dimensions

Dimension of degree
Grammar PTA topic almost can be done, some problems still need to ask for help
Object-oriented design capabilities The ability to model the problem to be solved by using object-oriented thinking is generally
Application capabilities Writing gadgets is not going to work.
Number of lines of code so far 3595

201621123002 Java programming Nineth Week of study summary

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.