1. This week study summary 1.1 summarizes the set and generic related content in the way you like (mind map or other).
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.
A: The main problem with this problem is to solve one or more whitespace problems when entering. You can create a scanner for line and in
read it in in.next()
the same way. You can also read using the regular expression String[] strings = Line.split(" +");
method.
Deleting elements in the list can use list.remove()
methods to delete elements, or use methods to remove list.clear()
all elements from the list.
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)
- New one
Map<String,Integer>
, key holds the word, value stores the number of occurrences of the word.
- Reads the content, reads one word at a time, and determines whether the content of the word is already present in the map, and if so, the value is
Key
directly +1
manipulated, and if it does not exist, a new key is generated and the value of value is assigned 1
.
- Using
Collections.sort()
and anonymous inner classes, the map is sorted by value value (that is, the number of Word occurrences), the values are the same, the letters are sorted, and the output is sorted.
2.2 Experimental Summary
A: The main thing in this subject is to determine if the map contains elements that are being manipulated, and to determine whether to Value
manipulate the values +1
or generate a new one Key
. The other is to use Map.Entry()
and Collections.sort()
sort the map.
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 Your code runs the result
3.2 pseudocode (Do not copy code, otherwise deduct)
- Create a new one
Map<Integer,List>
, the key is used to hold the row number information, the value of the line to store the content of the List
article statement;
- Another one
Set<String> set = new TreeSet<>();
, for storing all the words in the article content, TreeSet
the word sort;
- Iterate the elements of map and set into the array using iterators,
List<String>
each of which gets an element Set
that iterates through the elements in the map, and if the row includes the word, the row number information is stored List<Integer>
in an array until all the rows in the map are traversed. (Use nested for loop statement) Set
, output the word to the middle, and simultaneously output an array that records the word line number information;
- First
in.nextLine()
read the information that needs to be looked up, assuming line
that, then a new scanner on line, with the implementation of the in.next()
word is extracted from the sentence, using the map through the iterator obtained by the List
array, using contains()
methods and loop statements to determine List
contains all the words in the lookup information, and outputs the line count information and the contents of the corresponding row found 0 results
.
3.3 Experimental Summary
A: In the beginning of the idea is a Key
corresponding multiple Value
, and later looked to know that value in addition to storing the basic data types, but also storage List
arrays, so later on the basic use Map<Integer,List>
. In addition, I used several different types of arrays to hold the contents of the article information (some of the information is stored in List
line-by-row, some of the words in each line of information) and the number of rows of information, so in the process of writing to pay attention to distinguish between different List
functions, to avoid mixing; I've also compared the methods of other students. , which in contrast uses much less. But for the students of the code is not very understandable, so although things complicated point, but feel that their ideas are relatively easy to understand some.
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比赛
Creates a collection object, such as a list
4.1 Writing a search method using traditional methods
List<Student> search(List<Student> stuList, 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. (: The number of the school, name)
Traditional methods :
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)
use Stream () in Java8, filter (), collect () to write :
5. Generic type: Generalstack
jmu-Java-05-集合
the Generalstack of the title set
5.1 Code for Generalstack interface
5.2 Combining the subject with the previous work
ArrayListIntegerStack
What are the benefits of generics compared to
A: In the previous job, the way in and out of the ArrayListIntegerStack
stack is defined as Integer
type, so only the integer type object can be manipulated, the operation of the object single.
In the case, the method adopted a generic definition, can be multi-type object stack operation, so that the function of the stack more specific, for the stack, regardless of the internal storage of what type of data, can achieve these specific operations. And generics allow you to specify the type of elements in the collection, so that you can get a strong type, you can find an error during the code compile phase, and you don't need to use risky coercion type conversions.
3. Code Cloud and PTA
Topic Set:jmu-Java-05-集合
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.
Can you achieve your goals?
At the beginning of the school I set the goal is the weekly estimate code volume of 200 lines, a semester 4000 or so, from the current progress, basically can exceed 200 lines per week of code, the current code is about 3000 lines, from the beginning of the start of the first set of small goals are not far away (our store?? Omega??) Our store???
Week Time |
Total code Amount |
New Code Volume |
total number of files |
number of new files |
1 |
90 |
90 |
5 |
5 |
2 |
322 |
232 |
11 |
6 |
3 |
35W |
330 |
16 |
5 |
4 |
946 |
294 |
21st |
5 |
5 |
1347 |
401 |
26 |
5 |
6 |
1591 |
244 |
28 |
2 |
7 |
2118 |
527 |
31 |
3 |
8 |
2627 |
509 |
39 |
8 |
9 |
2912 |
285 |
42 |
3 |
4. Assess how much you understand Java
Try to evaluate how much you understand Java from the following dimensions
Dimension of |
degree |
Grammar |
PTA Most of the problem can be solved, but it takes a certain amount of time, every time the problem can meet some new content can learn |
Object-oriented design capabilities |
After thinking, we can generally grasp the direction of using object-oriented thinking to model the problem to be solved. |
Application capabilities |
Can solve more than half of the PTA exercises, extracurricular should also be able to write some simple small program |
Number of lines of code so far |
2912 |
201621123010 Java Programming 9th Week of study summary