Zero-based knowledge summarizes several key points of the Java programming language based learning

Many beginners new to the Java programming language Java program, do not know what is necessary to learn to master the basics. This article summarizes some basic knowledge you zero-based learning the Java programming language.

1 first understand what is Java-four

 

Beginners to understand the basic concepts of these Java is also essential, rote certainly does not work, focusing on understanding, understanding differences and relations between them, respectively, which applications. Think about what the code used in knowledge. Do not blindly shining books knock code. Without understanding.

1.Java programming language, grammar.

2.Java file format, that is, the various folders, file extension.

3.Java Virtual Machine (JVM), that is, the processing interpreter * .class files.

4.Java application program interface (Java API).

2 master static methods and properties

Static methods and properties are used to describe a type of object groups of features, rather than individual features of the object. A large number of applications in Java static methods and properties, which is a common technique. But this technique is not used frequently in many languages.

Understanding of static methods and properties for the understanding of the relationship between classes and objects is very helpful in a lot of Java specifications, static methods and properties are frequently used. Therefore, the learner should be understood that the static methods and properties. Java is on call methods and properties of the same, only difference in performance when it was declared, and c ++ this is different.

3 beginners need to understand the relationship of three JAVA technology platform

Java is divided into three systems, namely Java SE (J2SE, Java2 Platform Standard Edition, Standard Edition). JavaEE (J2EE, Java 2 Platform, Enterprise Edition, Enterprise Edition). Java ME (J2ME, Java 2 Platform Micro Edition, Micro Edition).

To know java is divided into two parts: one compiled a run.

javac: responsible for the compilation of the section, when executed javac, start the java compiler program. The specified extension .java files are compiled. Jvm bytecode generated file can identify. That is class file, which is run java program.

java:. partially responsible for running the jvm will start to load the required run-time library, and class files execute a file to be executed, there must be a starting point for the implementation of this starting point is the main function...

4 basic format grasp JAVA code

1, Java annotations as comprehensive as possible

For the method should contain detailed comments to the Senate and the results indicate that there are abnormal thrown also described in detail: functional annotation class description should include classes, authors and modified by.

2, preferably using the same multiple variables grouped into constant

Variables used in many of the same values ​​should be as summarized as a constant, to facilitate future maintenance.

3, is performed in as little loop method invocation

Try to do less in the cycle method avoids calling it saves create a method stack. E.g:

for(int i=0;i<list.size();i++){< p=""></list.size();i++){<>

System.out.println(i);

}

Be amended as follows:

for(int i=0,size=list.size();i<size;i++){< p=""></size;i++){<>

System.out.println(i);

}                                                                                                                      

4, can be put in defining constants interface

In Java, where the interface allows only constant, so the constants declared in the interface will save into public static final few key words.

5, ArrayList and LinkedList choice

This problem is more common. Programmers typically assess the list to make best use of the scenario, and then make a choice depending on the characteristics. The bottom layer is achieved using an array ArrayList, so random read data much faster than LinkedList, while LinkedList is implemented using a linked list, add and delete data a lot faster than ArrayList.

6、String,StringBuffer和StringBuilder

This problem is also more common. When performing string concatenation process, String typically produce a plurality of objects, and the plurality of values ​​into constant pool cache. E.g:

String a=“a”;

String b=“b”;

a=a+b;                                                                                                                      

In this case jvm produces "a", "b", "ab" three objects. And the performance of string concatenation is too low. It is often necessary to do string processing time to maximize the use of StringBuffer and StringBuilder.

7, packaging and basic types of selection

In the code, if the basic data types can be used to do local variable type, then make use of the basic data types, since the basic type of variable is located in the stack, the wrapper class variable is in the stack, the stack operation speed faster than the reactor a lot of.

8, as soon as possible will no longer use the variable reference is assigned to null

Doing so can help carry out jvm memory faster recovery. Of course, many people are actually not cold this practice.

9, release of resources in the finally block

A typical scenario is when using io streams, regardless of whether there should be an exception last closed finally in the stream.

10, a use in the HashMap Object to be noted that how to distinguish whether or not the same as the Key Object

In the jdk HashMap implemented, it is determined whether the two key type Object is the same standards are the same hashcode and equals the return value. If you need two identical memory data object as different service key stored in the hashmap necessary for covering hashcode and equals method.

The main embodiment described Java complex data structure is a set frame. Java no pointer, but describes an array of complex data structures, and so an array of objects through a strong frame set.

The method described in these data structures to learn applications written, particularly in relation to the server side, a three-layer structure is critical programming. At this time the programmer can not be reused, such as the database structures described results of the data set or the like.

Since many languages ​​do not have such a strong collection framework, many beginners know what to do, but do not know what to do with used to, and therefore should be taken seriously enough.

Guess you like

Origin www.cnblogs.com/gpxs/p/11634951.html