What is the basic knowledge of Java?

Source: Internet
Author: User
Tags prev

Recently, many people invited me to answer a variety of Java EE development of the primary issues, I do not have to emphasize that the beginning of the basic knowledge of beginners to a solid, what is the basic knowledge of Java? What is the basic knowledge of Java? The question is really worth thinking about.

I have been doing the development of the Java EE more than ten years, as an experienced, the mentality of the course estimates and everyone similar. In previous years of coding, it was easy to think of Java for a long time, to develop various functions, and to write code that was not laborious (mainly because the code was written in some functional business logic). But at the same time, I understand that in fact, they do not have any level, their 3, 4 years since the learning of things so much, other people can learn a few months, their competitiveness where? This contradictory psychology, troubled me for a very long time, very distressed! There is always a way to the motherland without a door to the feeling.

This period, enthusiastic about the use of various frameworks, a variety of APIs, often to learn an API today, components, the use of the framework feel that they have learned something, design patterns have seen more than once, but there is no feeling. On the one hand very hard study, on the one hand feel not practical, because for example this API I know and you do not know, but I tell you then you know, then I more than your advantage where? Distress

After a long period of such fear, deciding to change, the direction of change is to read the Java-related source code you use to see how the JDK is implemented. From the basic data structure, and then look at multi-threading related, in the learning foreground and so on. The code or the code, the code is still so simple, but I strive to know the truth behind the code, this is the direction I started. So no longer spend time on the pursuit of new frameworks, the use of new APIs, every day to spend time to see the principle of implementation. In this way over the big six months or so, finally no longer confused, will not feel that they only understand the use of the API, feel that they are not so superficial, said the reborn is not too. During that time, I was the fastest growing period, but also the most fulfilling time.

Talk is cheap,show me the code. For example, people will have more feelings.

If you have learned the HashMap source code and know how it works, use HashMap

Map<Integer, String> map = new HashMap<>();

The code is still the code, but I already know what's behind HashMap.

    1. The data structure is an array of linked lists (note: Later versions are changed to a linked list or tree (more nodes) in order to improve performance)
    2. Thought is the algorithm of space change time
    3. There are 2 parameters of capacity and load factor on the constructor and the function
    4. The performance is determined by whether the hashcode of key is fast enough, the results are scattered (it will become the performance of the list), and the cost of the expansion (when the expansion, and load factors)

Then when writing code, if you know the final capacity (especially when the data is large), I will specify the initialization capacity, similar to the following

List<SomeBean> list = doSomeThing(); Map<Integer, String> map = new HashMap<>((int)(list.size()/0.75));//0.75为默认负载因子

If you have a particular map in your work and the performance needs to be optimized, I'll consider optimizing the

    1. If the key is an object of its own definition, then is the Hashcode method fast enough (should the cache be guaranteed to be counted only once, and cannot be changed after it is placed, the Hashcode field cannot be changed)? Is the result of hash scattered enough?
    2. Consider adjusting the load factor to take more space to change time.

Learning the source code, especially interesting, you will strongly feel a word: extrapolate! Comprehend by analogy Learning API when using, if you only know the use of the principle of not knowing, it is difficult to extrapolate, feeling is rote. But after learning the principle, knowledge into the system, it is easy to extrapolate, learn more easy, or hashmap for example, I lift a hashmap anti three points.

1. You will know that whenever there is an array of data structures, the constructor has a capacity initialization parameter (or the constructor may have an initialization capacity that is the data structure of the array). The constructor is as follows

public ArrayList(int initialCapacity) //LinkedList不是数组就没有public HashMap(int initialCapacity) public StringBuffer(int capacity) 

You will know that array expansion is very expensive (data volume is large and easy to oom) and the capacity is specified as much as possible.

2. The algorithm is the space to change the time, there is no other algorithm is this idea? You can at least find a bucket sort.

3. Database sub-list, thinking and HashMap similar

4. A variety of distributed hash consistency algorithms, the first step is to create a maximum array (integer.max_value), is to avoid the HashMap maximum performance of the expansion operation.

After learning HashMap, you will naturally learn about other maps, such as TREEMAP,LINKEDHASHMAP (Super Useful), Hashtable,concurrentskiplistmap (algorithmic thinking is very interesting), Concurrenthashmap and so on, you will know that set is done by map, and no need to learn. By this step, map related can be suspended.

In the study, I found that the ideological things are the most important, you understand the thought, suddenly suddenly enlightened, in also do not need to memorize. When learning CAs, we all know that this is an instruction-level lock-free implementation. When I looked at the code, I wondered why there was a while loop (forgive my talent keenness)

 PublicFinalIntGetandupdate(intunaryoperator updatefunction) { int prevnextdo {prev = get (); next = updatefunction. Applyasint (prev} while  (! (prevnextreturn prev              /span>                

Later from the ideological understanding, just know the concept of optimistic lock, is very optimistic, assuming you will not go wrong, but if you make a mistake I will try to fix you, the corresponding is pessimistic lock, is very pessimistic, feel that the lock will be wrong, such as synchronize keyword and reentrantlock. This embodies 2 different management ideas. This idea is often embodied in the design of multiple systems integration, sometimes if you use pessimistic thinking design, implementation is cumbersome or impossible to achieve, but if you use optimistic thinking, reduce error conditions, and then error can be solved, the cost will be much smaller.

All I'm saying is that the basic knowledge of EE is what you do behind the code in your project. The way to improve your own level is very simple, is to spend most of the time to understand the principle of realization, understand the idea, let their knowledge strung together to form a system. The knowledge of the Java EE is particularly much, learning people want to cry, do not start to spend time on various frameworks, components of the use, in my opinion that is the cart before the horse. Simple: First repair the internal strength and then practice the moves.

What I think is important is that work can be used in the knowledge that is a request from the foreground to the background processing needs to use the thing, at least include the following points: Js,html,css,ajax,ajax cross-domain, cross-site scripting, Web caching, web optimization, Nginx,apache role, authentication method, Cookie,session,servlet,filter, basic data structures, thread pooling, threading concurrency, caching, IO, etc., have a lot of knowledge. If your front desk uses JQ, you should understand how his selectors and Ajax are implemented (in fact, to understand will find not complicated)? Instead of just using it. Backstage you use SPRINGMVC, you want to understand how he works, every configuration is what to do, why?

The knowledge point of the Java EE is very many, each one can write many, I also in unceasingly studies. Specifically to write I really do not know how to do, I would like to list what I feel the basis of the things (interview questions asked), there are simple and difficult, you think the bias may be you have not done this piece of development or do relatively shallow:

    What are the
    1. map features and usage scenarios? (only know hashmap,hashtable is not enough ...)
    2. What aspects affect the performance of HashMap?
    3. What are thread-safe maps and how Concurrenthashmap is thread-safe (jdk1.8 big difference)? What kinds of
    4. locks are there?
    5. How does a fair lock, read-write lock, etc. be implemented? Where can I add the
    6. synchronize? What's the difference?
    7. What is the condition of the deadlock? It's very rare now to be locked down, and seldom ask the principle of the
    8. Atomic data object?
    9. Reentrantlock related knowledge, condition how to use? (Very important knowledge points, highly recommended reading Arrayblockingqueue source code, textbook-like)
    10. volatile knowledge (memory barrier, reflow)
    11. threadlocal principle and use? (Super useful knowledge points, work in a lot of, let the code pretty much, behind the special write)
    12. multiple threads synchronous wait? (Countdownlatch,cyclicbarrier,semaphore semaphores are available in many languages, in fact not many, the thread pool can implement most of the wait functions)
    13. thread pool? (Kind, important method, this is generally use plane, simple)
    14. dynamic proxy? Reflection? Introspection? (Study knowledge)
    15. session related? and cookie relationship? Distributed session implementation principle?
    16. cookie-related knowledge? What are the properties? (Some properties are useful, but we seldom pay attention!)
    17. Nginx,apache What can the actual project do? (Authentication, forwarding, caching, reverse proxy, etc.) and what is Tomcat's relationship? Understand the
    18. Ajax cross-domain reason at a minimum? How to solve? (Key knowledge, do se can not avoid the problem.) Here a lot of knowledge points. )
    19. jsonp principle? Do you need to change the background? (Jsonp is now out of the question, but still asks)
    20. Web optimization knowledge points? (General knowledge Point)
    21. foreground cache related? (200cache,304,ajax cache, how to implement caching)

The list will not stop at all ... Other spring frameworks are also a lot of things, there are JVM things, system integration related, database-related, io do very little do not know the question, and then slowly put my learning process and even write down. A lot of things I also know about, is to see if you have learned, continuous learning is the most important feature of programmers.

I am not a master, can only be counted as a qualified old programmer. Here is just a bit of the direction of their study before and listed a few examples of learning, we have a matter of opinion. The post is also aimed at the confusion of the beginning of the feelings of the hair, hope to help everyone.

Finally, I summed up: beginners first broad in the fine, pay attention to the implementation behind the code, pay attention to the internal training, understand the realization of principles and ideas, form their own complete technical system, the knowledge is easy to comprehend by analogy after the film, the speed of progress will be more and more fast. Finally, I am in each project team and developers chat will say a few examples end: "Shaolin Kung Fu and boxing points, horse work, Shikong is work, snake boxing monkey style is boxing, you can not practice the Snake Fist Monkey style will be able to hit, you must first focus on practicing." Qiao in the village with the founder Chang Chang Quan to beat everyone, we use the founder Chang Quan is just a calisthenics. Similarly, we want to distinguish between the programming of those are the work of those who are boxing, the implementation of the code behind and the idea is working, the various frameworks, API use is boxing. Beginners should spend most of their time in practice, the punch will naturally have, do not cart before the horse. "Thank you all for reading!"

What is the basic knowledge of Java?

Related Article

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.