"Cuối cùng! Tôi nhớ bạn. Bạn đã ở đâu? Đây là một số nhiệm vụ cho bạn."
"Chúng có thú vị không?"
"Tất nhiên. Rất thú vị:"
2
Nhiệm vụ
Java Syntax, mức độ, bài học
LinkedList and ArrayList
Collections can be implemented in many ways. There is no single implementation that is the most correct. In one approach, some operations are fast, but others are slow. The opposite can be true for another approach. There is no perfect one-size-fits-all solution. We won't torture you by making you choose. Let's just immediately create two different types of lists: LinkedList and ArrayList.
5
Nhiệm vụ
Java Syntax, mức độ, bài học
10 thousand deletions and insertions
The ability to repeat monotonous actions without whining or goofing off is what makes computers glorious — and it's also what stops programmers from simply keeling over dead! Without a way to automate repetitive actions, the conditions for this task would sound like a prison sentence. As things stand, everything will be just fine: using an ArrayList and LinkedList, perform 10,000 insertions, deletions, and get and set calls.
2
Nhiệm vụ
Java Syntax, mức độ, bài học
Time for 10,000 insertions
Time is our most valuable resource. But we don't have any power over time anywhere, except on the planet of Tralfamadore. That's why there are no programmers on Tralfamadore, while Terra is full of them—because they help other people save time. Let's celebrate automation by measuring how long it takes to perform 10,000 insertions on a LinkedList and an ArrayList.
2
Nhiệm vụ
Java Syntax, mức độ, bài học
Time for 10,000 get calls
How much time and effort are you willing to spend to get something good? As long as it takes, we think. After all, you're currently trying to become a programmer. Let's see how long it takes to make 10,000 get calls on a LinkedList and an ArrayList. The getGetTimeInMs method must return its execution time in milliseconds.
2
Nhiệm vụ
Java Syntax, mức độ, bài học
Method quartet
In this task, we'll be working with a LinkedList and an ArrayList as follows. We need to implement 4 methods. Each of them should return the list that is best suited for performing the corresponding operations (i.e. the list that can most quickly perform a large number of operations). But you don't need to measure anything.
10
Nhiệm vụ
Java Syntax, mức độ, bài học
Longest sequence
If numbers repeat themselves, does that mean that somebody wants it that way? At present, we need repeated numbers to practice completing tasks with lists. Let's create a list of numbers and add 10 numbers from the keyboard. Our task is to display the length of the longest sequence of repeating numbers in a list.