Home  >  Article  >  Java  >  Some experiences using java

Some experiences using java

零下一度
零下一度Original
2017-06-28 09:09:001610browse

The purpose of writing this article is to summarize some of my experience in using Java over the years, mainly related to some basic Java knowledge points, so I also hope to share it with Java programmers who have just started and those who plan to enter. For those who are new to the Java development industry, I hope I can give you some experience so that you can learn and use Java better.
The main content introduced this time is the part related to J2SE. In addition, some J2EE-related content and content related to various frameworks in Java will be introduced in the future.
After so many years of Java development, and combined with some experience in interviewing Java developers, I think the main thing to master about J2SE is the following content.

1. JVM related (including features of each version)

For those who are new to Java, JVM related knowledge does not necessarily require a deep understanding. Just have some simple understanding of the concepts inside. However, for a senior developer with more than 3 years of Java experience, it is almost unacceptable to not know the JVM.
JVM is the basis for running Java. It is hard to believe that people who don’t know anything about JVM can understand the Java language thoroughly. When I interview developers with more than 3 years of Java experience, JVM is almost a must-ask question. Of course, JVM is not the only interview question that determines the quality of technical capabilities, but it can prove the level of Java development capabilities.
In the category of JVM, I think the knowledge that needs to be mastered is:
JVM memory model and structure
GC principles, performance tuning
Tuning: Thread Dump, analysis of memory structure
class binary bytecode structure, class loader system, class loading process, instance creation process
Method execution process
New features provided by major Java version updates (need to be briefly understood)

2. Running Java (Basic Essentials)

This may seem simple. Who doesn’t know how to run a Java program? But many times, we just execute java programs through IDE. How does the underlying IDE execute java programs? Many people don't understand.
This knowledge point is the most basic thing that Java developers need to master. When learning Java for the first time, the first step is to teach you how to execute Java programs on the command line. However, once many people finish learning Java, they use IDEs. , just forget about this. Why emphasize the need to know this? After knowing the purest startup method of Java, you can analyze the number of directories started at that time, the execution naming, parameters, and whether there are any missing, etc. when there is a startup problem. This will help you solve those weird problems that may be related to the environment during actual development.
The knowledge you need to master here is:
javac compiles java files into class files
The use of the java command, how to start the java class with package in the command line
The various paths involved in the java program (classpath, java.library.path, the home directory where java is running, etc.)

3. Data type

There is not much to say about this, it is nothing more than Java Mastery of basic types and object types. You can learn more about how JDK automatically converts, including boxing and unboxing, etc., and also pay attention to avoid judging type equality after boxing
Main knowledge points:
Basic types: int, long, float, double, boolean, . . .
Corresponding object type: Conversion of Integer and other types to basic types, boxing and unboxing
Object type: equals, hashcode
Characteristics of String type

4. Object And instances, object creation

In this regard, developers need to understand the concepts of class and instance and the differences between them, which is a basis for the object-oriented features of Java. The main knowledge points are:
The concepts of Class and Instance
Instance creation process:
 1. No inheritance: allocate memory space, initialize variables, call constructor
 2. There is inheritance: processing static actions, allocating memory space, defining variables as initial values, from the base class -> subclass, processing initialization at the definition, executing the constructor method
Points to note:
Static properties, etc. Base class -> Subclass initialization
Features related to the default no-argument constructor

5. Access control

This is also a basis for java encapsulation features , what needs to be mastered are:
public protected default private Modification of class, method, field

6. Process control

 The basis of Java process control, Although some syntaxes are not necessarily commonly used, you need to understand them and use them where appropriate.
What you need to master are:
if, switch, loop, for, while and other process control syntax

7. The concept of object-oriented programming

This is a core concept of java that any java developer needs to be proficient in. Many features or knowledge points in Java are related to Java object-oriented programming concepts. In my understanding, a good developer not only needs to understand these features (knowledge points) themselves, but also needs to know how these objects are reflected in Java's object-oriented programming concepts. This will be more conducive to developers mastering Java. This development language, as well as other object-oriented programming languages. Here is just a brief list. The main knowledge points include:
The three major characteristics of object-oriented: encapsulation, inheritance, polymorphism; their respective definition concepts, which characteristics are reflected, and their respective usage scenarios
Static The concept of multiple dispatch, dynamic single dispatch
The concept and use of overloading
Inheritance: multiple implementations of interfaces, single inheritance of base classes
Abstraction, abstract classes, interfaces
Polymorphism: the concept and use of method coverage Use
interface callback

8. Static

Static attributes are also often used in daily Java development. You need to understand the usage related to the static keyword, and Use with other keywords, such as whether it can be used in conjunction with abstract, final and other keywords.
The main things you need to master are:
The definition and use of static attributes, and how to initialize when a class is loaded
The definition and use of static methods
The definition and use of static classes
The use of static code blocks Definition and initialization timing

9. Basic knowledge points

Here are some scattered Java knowledge points that are not systematically classified. It is also used a lot in daily development. There is actually a lot more to this piece of content, but I have just temporarily summarized these here:
Including:
equals, hashcode, string/stringbuffer, final, finally, finalize

10. Collection Framework

This is a part that needs to be mastered more. When doing Java development, it can be said that there is no need to use the collection framework, which is very important. But the knowledge points here are not difficult, but it is best to understand the internal implementation of collections, because this will help you choose a suitable framework to solve the problem in different scenarios. For example, a collection with 10,000 elements often requires Performing the contains judgment operation, knowing the characteristics or internal implementation of the collection, it is easy to make the right choice.
The following content is included here (concurrency related is not included):
System of the collection framework: Basic Collection, Map
Contents of specific collection implementation, List, Set, Map specific implementation, internal structure, Special methods, applicable scenarios, etc.
Usage of collection-related tool classes Collections, etc.

11. Exception framework

Exceptions may not be that important in Java development emphasized. Generally, when an exception is encountered, it can be thrown directly, or it can be handled casually and it will not have any major impact on the overall operation of the program. However, in enterprise-level design and development, the quality of exception design and handling is often related to the overall robustness of the system. For developers, the exception handling of a good system should be unified to avoid a lot of exception handling logic scattered everywhere; for the system, exceptions should be controllable and easy to operate and maintain. After certain exceptions occur, There should be ways to deal with it and know how to operate and maintain it. Therefore, although the exception framework is very simple, exception handling is very important for the entire enterprise-level application development. To handle exceptions well, you need to understand the exception system in Java.
There are not many knowledge points that need to be mastered in this part. The main ones are:
Exception system:
Throwable
Exception
RuntimeException
Error
The difference between RuntimeException and general Exception, specifically Processing methods, etc.

12. Java IO

IO in Java is not just as simple as file reading and writing, but also includes socket network reading and writing, etc. Input and output operations. For example, reading the content of Post in a standard HTTP request is also an output process, etc...
For IO, Java not only provides basic Input and Output related APIs, but also provides some Readers, Writers, etc. that simplify operations. API is also very important in some development (projects involving a large number of IO operations), and is also involved in general daily development (logs, reading and writing of temporary files, etc.).
The main knowledge points here are:
Basic IO system: including InputStream, OutputStream, Reader/Writer, file reading, various stream reading, etc.
The concept of NIO, specific usage methods And usage scenarios

13. Multi-thread concurrency

Multithreading is generally considered a difficult area in Java. Multi-threading can effectively increase CPU usage and improve overall system efficiency, especially when a large number of IO operations are blocked; but it is also a double-edged sword. If it is not used properly, the system will not improve much, or There is no improvement, and it will also cause problems such as debugging between multi-threads.
There is a lot of content in multi-threading. I just briefly explain the knowledge points that need to be mastered for the initial use of multi-threading in Java. In the future, I will have the opportunity to introduce the usage scenarios of some advanced features in detail.
Multi-threading implementation and startup
The difference between callable and runable
syncrhoized, reentrantLock's respective characteristics and comparison
Thread pool
future asynchronous way to obtain execution results
concurrent package
lock
..

14. Network

Java also provides APIs that can directly operate the TCP protocol and UDP protocol. When network performance needs to be emphasized, TCP/UDP can be used directly for communication. By viewing the source code of Tomcat, etc., you can see the usage of these related APIs. However, TCP is generally rarely used directly, and frameworks such as MINA and Netty are used for processing. Because there is not much development in this area, I will not list it in detail.

15. Time and date processing

For almost every application, time and date processing cannot be bypassed, but the usage of time-related APIs before JDK8 is not Not friendly. In those days, time frames such as Joda were available. After the release of JDK8, the new time API basically integrates the advantages of other frameworks and can be used directly.
For Java developers, they need to be proficient in using APIs to process time and date.
The specific knowledge points are no longer listed. I will write a special article in the future to summarize the usage of the time and date API in JDK8.

16. XML parsing/JSON parsing

In fact, these two pieces of content are not in J2SE, but in daily development, they interact with other programs and configure File interaction is increasingly inseparable from the analysis of these two formats.
However, for a developer, being able to understand some specific principles and methods of XML/JSON parsing will help you better choose the appropriate method in each specific scenario to make your program more efficient. and more robust.
XML: You need to understand the basic principles of DOM parsing and SAX parsing and their respective applicable scenarios
JSON: You need to understand the usage of some common JSON frameworks, such as Jackson, FastJson, Gson, etc. .

17. The use of Maven

Maven is not part of Java, but Maven is revolutionary and brings great convenience to Java development. From the introduction and management of dependencies, the update of development processes and release outputs, and even version updates, using Maven can greatly simplify the complexity of the development process, thereby saving a lot of time. It can be said that maven has become the standard for Java developers. Therefore, I regard maven as a necessary basic knowledge point for a java developer. In the future, I will add some of my experience and skills in using Maven, etc., so I won’t go into details here.

18. Generics

This is a new concept introduced in JDK5. It is actually a syntactic sugar. It will be somewhat convenient when writing java code. General applications or It is business development. It only needs to be used simply. Operations such as defining generics may not be used. However, it will be used when developing some basic public components. You can take a closer look at this part when needed. Generally speaking, as long as you can use it simply That’s it.

19. The annotation

was also introduced after jdk5. Spring is an excellent framework that uses xml as the standard configuration file from the beginning. However, after Spring 3, especially after the rise of spring-boot, the use of annotations to simplify xml configuration files has become more and more popular. For developers, it can save a lot of time in xml configuration. But the disadvantage is that the annotations are scattered in various classes. Unlike XML, you can have a global understanding and management of all configurations, so there is no way to completely replace all XML. For ordinary developers, it is enough to use annotations. Some publicly organized developers may need to understand the definition and implementation of annotations, and can take a closer look when needed.

20.RMI

RemoteMethodInvocation, a remote calling interface unique to the Java language, is relatively simple and convenient to use. However, if cross-language support is required, other methods such as webservice must be used to support it. Generally speaking, programs do not need to use RMI, but it can be used under specific circumstances. In a project, I used RMI to control the remote start and stop of the program.

21.JNI

Java Native Interface allows calling local interface methods in Java and is generally used for calling C/C++ code. What needs to be noted is the path problem of loading so/dll files in Java. Calling the interface itself is not complicated, but it often takes a lot of time to check whether the required local interface library is loaded.

The above is just a brief introduction to some of my views and introduction to these basic Java knowledge points and technical points. These contents are derived from some summaries of my use of Java over the years. I hope to give some advice to those who have just come into contact with Java, or who plan to start from Java developers have some experience, hoping to learn and use Java more efficiently and avoid taking detours and wasting precious time. There are still some imperfections in the content, which will be added in future articles. Due to my limited personal ability, of course there will be some errors and omissions. I welcome corrections, discuss together, and work together to improve this article. I hope it can really help people in need.

Attention, students learning Java! ! !

The above is the detailed content of Some experiences using java. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn