|
Serial number |
The wording of the promotion |
Reason |
|
1 |
Try to use a single case on the right occasion |
Reduce loading burden, shorten loading time and increase load efficiency |
|
2 |
Use the final modifier as much as possible |
Find inline all final methods with 50% better performance |
|
3 |
Use local variables as much as possible |
instance variables and static variables are built in the heap, slow, local variables are placed in the stack, fast |
|
4 |
Handle the package type and basic type usage scenarios. |
The wrapper type belongs to the object created in the heap, the base type is created in the stack, there are objects that need to handle the applicable wrapper type, others advocate the basic type |
|
5 |
Using synchronized sparingly to minimize synchronized method |
Implementation of synchronization system overhead, easy deadlock. Try to apply method synchronization instead of code block synchronization |
|
6 |
Try to use StringBuffer and StringBuilder for string concatenation |
Try to initialize StringBuffer and StringBuilder lengths, character arrays dynamically add strings |
|
7 |
Try to replace objects with basic data types |
such as String str = "Hello" string str = new string ("Hello"); The latter also creates an array of characters |
|
8 |
Single thread try to use HashMap ArrayList |
HashTable Vector uses a synchronization mechanism to reduce performance |
|
9 |
Use HashMap as reasonably as possible |
Using HashMap's construction method, initializing its size, scaling is a very expensive thing. |
|
10 |
Try to free resources in the finally block |
Avoid resource leaks |
|
11 |
Try to replace A/B,A*B operations with bitwise operations |
/is a very expensive operation |
|
12 |
Release useless objects as early as possible |
OBJ =null |
|
13 |
Rational use of ArrayList and LinkedList |
One is a linear table (query), one is a list (add and delete), |
|
14 |
Try to copy an array using System.arraycope |
is much faster than copying an array in a loop. |
|
15 |
Try to cache frequently used objects |
Hashmap,weekhashmap or third-party tools Ehcache Oscache Memcached |
|
16 |
Large objects try to use Clone () without new |
New object creation Cost large |
|
17 |
Use the API provided by Java itself as much as you can |
Don't explain |
|
18 |
Using the fast-speed JDBC Driver |
Database Connection Pool |
|
19 |
Cache Datasorce |
In order to re-invoke Jndi, you can cache the Datasorce that you want to use in the system |
|
20 |
To make the Setget method of accessing the variables in the instance become final |
can become inlined |
|
21st |
Charat instead of StartsWith |
-- |
|
22 |
If there is only one character "instead" " |
-- |
|
23 |
Constant string instead of StringBuffer |
Reduce running overhead to improve performance |
|
24 |
StringTokenizer instead of indexof substring |
StringTokenizer parsing strings is easier and more efficient |
|
25 |
Replace If-return else with a three mesh operation |
-- |