preface
Only a bald head can be strong.
Star: github.com/ZhongFuChen…
Those of you who know me probably know that I have written a number of serial-level articles, but none of them are written for beginners. Most of them are written at my own pace.
Although you can follow the order of my articles to read one by one, but if you are new to the students may want to get a study guide (route guide). So I have this article, I hope to help the students who just started.
If the response to this article is good, we will continue to update other topics. Think I write good, hope can give me a thumbs-up!
Java Collection learning Guide
This article will raise a lot of questions that may come to mind for beginners, but will not answer them all. It will only explain the general direction. The content of this article is more of a guide than a technical tutorial.
For more concrete answers, check out the materials I’ve written about: github.com/ZhongFuChen… Or join the talent exchange group to discuss with many developers. The Github link above has my contact information.
Before you learn a technology, you must know why you are learning it!
Q: We need to know why we learn Java collections. We learned arrays when we learned Java collections. Why I use Java collections instead of arrays. What’s the difference between arrays and Java collections?
A:Java is an object-oriented language, so we have to deal with objects. To make it easier to manipulate multiple objects, we have to store these objects. If we want to store multiple objects (variables), we can easily think of A container (collection) to store them
In summary: Java gives us the tools to manipulate multiple Java objects.
How to get started with Java Collections
Q: Now that we know why we need to learn Java collections, we should know the basic usage of Java collections and understand what they are from the whole point of view
A: We learned About Java collections in order to manipulate multiple objects, and Java gives us A series of apis (methods) to manipulate. So when you’re starting out with Java collections, it’s more about learning what these apis mean.
Q: Now that we have some understanding of the API usage of Java collections, we should start to understand it from an object-oriented perspective. Why are multiple interfaces abstracted, and what are the features of each interface?
A: We can summarize several common implementation classes, which we have to know what the data structure is and when to use the class.
Data structures to learn and understand:
At this point, after a brief look at the data structures of the various implementation classes, we might simply remember the following conclusion:
- If it’s a collection type, we have a List and a Set to choose from. A List is characterized by ordered inserts and repeatable elements. The characteristic of a Set is that the inserts are unordered and the elements are not repeatable. Choosing which implementation class to use as our storage container depends on the specific application scenario. If you want to be repeatable you have to use List, which is a common subclass of List. If you want to be unrepeatable, select a common subclass of Set.
- If it is
Key-Value
Type, then we will choose Map. We can select LinkedHashMap if we want to keep the insertion order, HashMap if we don’t need it, and TreeMap if we want to sort. - Bottom line: After learning the data structure of a common implementation class, you should have a clear idea of how it can be used.
Set progression and interview
If we know what collection to choose as our container when we write code, we’re already getting started. But know that if you go into an interview, you should know more than that.
(If you are a beginner or a beginner, I suggest you skip this section. There are many comments on the Internet, such as “If you have a solid Java foundation, you will have a good job in the future. When learning Java foundation must learn the foundation well, see source code!” . But IN my opinion, this section is established when there is a certain amount of coding/project or when looking for a job, a beginner learning Java, should not read the source code, it is easy to dissuade yourself)
My point is that if you’re new to Java, it’s enough to know exactly why you’re learning it, what it does, where it’s used, and to be familiar with the common methods. Even if you’ve spent two weeks or so looking at the source code implementation, you probably understand it. But, trust me, you’ll probably forget.
Java collection is the focus of the interview, I interview almost every company will ask the collection questions, from the basic to source, step by step in-depth. Java collection interviews are not limited to basic usage. The interviewer may ask you:
- What is the data structure of a HashMap? How did he expand? Are there any red black trees at the bottom? Take Key Hash value is JDK source code how to implement? Why do you do that?
- Is HashMap thread safe? What is thread safety? What’s a better solution? How is thread-safe HashMap implemented?
- How does a HashSet determine that a Key is duplicated?
- . Many, many
For more concrete answers, check out the materials I’ve written about: github.com/ZhongFuChen… Or join the talent exchange group to discuss with many developers. My contact information is linked to the previous article.
The original brain map is also available on GitHub
The last
Server 89/ year, 229/3 years, buy to send yourself, send my girlfriend for the New Year immediately more appropriate, bought to build a project to see the interviewer also sweet, but also familiar with the technology stack, (old users with family accounts to buy, I use my girlfriend 😂). Scan or click to buy
Build tutorial, from 0 to take you step by step to build 😂
Overall, getting started with Java collections isn’t that hard, and it boils down to three things I think:
- See why you should learn Java collections
- Learn the various interfaces to Java collections and common implementation class usage
- Learn what the data structures of common implementation classes are so that you can choose an appropriate implementation class to load your own objects when writing code.
You don’t need to read the source code to get started. Review and read the source code before your interview!
This has been included in my GitHub featured articles, welcome to Star: github.com/ZhongFuChen…
Happy to export dry Java technology public number: Java3y. The public account has more than 300 original technical articles, massive video resources, beautiful brain map, attention can be obtained!
Thank you very much talent can see here, if this article is written well, feel “three crooked” I have something to ask for praise for attention ️ to share 👥 to leave a message 💬 for warm male I really very useful!!
Creation is not easy, your support and recognition, is the biggest motivation for my creation, we will see you in the next article!