What should you pay attention to when learning Java programming from scratch?

1. When self-study for novices, remember not to start by reading books.

Many people who are learning Java from scratch, because they have never been exposed to programming, their first idea is to buy a book.

Students who have read textbooks know that such books are often very boring and have poor readability.

At the same time, it is almost useless for novices to learn Java programming and read books, which is a waste of time.

Java programming textbooks are all theoretical, and there are many professional words in the book. Generally, novices cannot understand it if they do not know how to operate it. Therefore, it is very inefficient for novices to self-study by reading textbooks.

2. Master static methods and properties

Static methods and properties are used to describe the characteristics of a certain type of object group rather than the characteristics of a single object.

Static methods and properties are heavily used in Java, and this is a common trick. But this technique is not used frequently in many languages.

Understanding static methods and properties is very helpful for understanding the relationship between classes and objects. In a large number of Java specifications, static methods and properties are frequently used.

Therefore learners should understand static methods and properties. Java is consistent in calling methods and properties. The difference is only reflected in the declaration, which is different from C++.

3. The relationship between Java’s three technology platforms

Java is divided into three systems, namely Java S, EJavaEE, and Java ME.

You must know that Java is divided into two parts: one is compilation and the other is running.

Javac: Responsible for the compilation part. When Java is executed, the Java compiler program will be started. Compile the .Java file with the specified extension. A bytecode file that can be recognized by the jvm is generated. That is, the class file, which is the running program of Java.

Java: The part responsible for running. It will start the jvm, load the class libraries required for runtime and execute the class file.

4. Master the basic format of Java code

1. Java comments should be as comprehensive as possible

Comments on methods should include detailed descriptions of input parameters and results, and detailed descriptions of exceptions thrown; comments on classes should include descriptions of the class's functions, authors, and modifiers.

2. The same variables used multiple times are best summarized as constants

Variables with the same value used in multiple places should be summarized as a constant as much as possible to facilitate future maintenance.

3. Perform as few method calls as possible in the loop

Try to make as few avoidable method calls in the loop as possible, which can save the creation of method stacks.

4. The definition of constants can be placed in the interface

In Java, only constants are allowed in interfaces, so by declaring constants in the interface, you can omit the keywords public static final.

5. Choice between ArrayList and LinkedList

6、String,StringBuffer和StringBuilder

7. Selection of packaging types and basic types

8. As soon as possible, assign variable references that are no longer used to null.

9. Release resources in the finally block

10. When using an Object as a key in a HashMap, pay attention to how to distinguish whether the Object is the same.

The main way Java describes complex data structures is the collection framework.

Java does not have pointers, but uses a powerful collection framework to describe complex data structures such as arrays and object arrays.

Learning the description methods of these data structures is crucial for application writing, especially when it comes to server-side and 3-layer structure programming.

Programmers at this time can no longer use structures such as database result sets to describe data.

Guess you like

Origin blog.csdn.net/Itmastergo/article/details/132895578