In this level, you continued to get acquainted with collections: you figured out what HashMap and HashSet are, and also learned more about the methods of the Collections helper class. In the context of HashSet, it was relevant to talk about another type of loop: the for-each loop, which will help you display a list of HashSet elements on the screen.

Finally, a completely new topic for you is the multiple-choice switch statement.

In general, we suggest that you breathe in and breathe out, and then close out these topics completely (for now) — carefully read a few additional lessons. It will not be boring!

Collections class

There are some tasks that ArrayList is just perfect for. Java's creators took and implemented them in a separate class so that you and other developers don't have to implement them yourself every time. In this article, you will learn about these tasks and the Collections class.

For-each loop

As you already know, a for-each loop is a kind of for loop that you use when you need to process all the elements of an array or collection. In this lesson, you will find examples of using this loop with a data array and a collection, and you'll watch a helpful video on how this type of loop works. And if that weren't enough, say hello to additional reading from our very own students regarding for and for-each loops. And additionally, a selection of alternative methods for working with collections in Java.

Java's switch statement

Imagine that you're a knight stopped at a fork in the road. If you go left, you will lose your horse. If you go right, you will gain knowledge. How would we represent this situation in code? You probably already know that we use constructs like if-then and if-then-else to make these decisions. But what if the road splits not into two, but into ten?

You have roads that are "completely to the right", "slightly to the left of that", "a little bit more to the left" and so on, totaling 10 possible roads? Imagine how your "if-then-else" code will grow in this version! Suppose you have a 10-way fork in the road. For such situations, Java has the switch statement. We'll talk about this fellow several more times.

LinkedList

The Java programmer does not live by ArrayList alone. There are many other useful data structures. For example, a linked list, aka LinkedList. Already formed first impressions of LinkedList, but haven't yet thoroughly investigated what its features are? Read the article and you will understand much more about how this data structure works and what benefits it offers!

HashMap: what kind of map is this?

Let's not ignore yet another data structure from the previous lessons. Have you already figured out what a HashMap is? Very good. But if you feel insecure and think that HashMap is not one of your strengths, read the article and immerse yourself. It contains tons of useful examples.

How to use the Enum class

You already know how to create classes. But what if you need to somehow use a class to limit a range of values? Before Java 1.5 appeared, developers independently came up with a "multi-step solution" to this problem. But then the Enum class came onto the scene to address this problem, and it came with all the capabilities of classes along with some peculiarities. In this article, you will learn how it differs from other classes.

Enum. Practical examples. Adding constructors and methods

And a few more words about Enum. More precisely, fewer words, but more code and practice. After all, the brains of many people are (quite often) full of mush on this topic rather than knowledge. If you want to get a better feel for the topic, don't be shy: feel free to read and explore as you go.


undefined
14
Опрос
Collections, part 2,  14 уровень,  8 лекция
недоступен
Collections, part 2
Collections, part 2