Due to restrictions of Java virtual machineCodeThe length cannot exceed 65535 bytes. I have summarized the related solutions to this problem.
1. Database
This is the most traditional method, and most people first think of it.
2. File
This is actually another way to replace the database.
3. Class
Refine complex classes into multiple classes.
4. Method
Refine complex methods into multiple methods.
In fact, the introduction of these four solutions is not the focus of this article, but fromProgramPerformance. Sometimes some relatively static data can be stored in a database or file, but both the database and file involve performance issues such as connection and IO. Some may say, I can pre-load static data (that is, get it only once and store it in static variables), but all the data with a large amount of data is stored in static variables, the result is the system's consumption of memory resources. In my opinion, there is also a trade-off.
If it is put into a class or method, the above problem can be well solved. The speed bottleneck of calling between Java files has been reduced to the JVM level. both speed and energy consumption will satisfy you. In terms of reading speed, it is definitely much faster than reading the database. In terms of energy consumption, we no longer need to put a large amount of data into static variables. When can we use new.
There are always many ways to solve problems, so we should not just limit ourselves to "common sense". flexible use of technology is a shortcut to growth. You will not try to store some data in the form of classes or methods in the future.
This is a good example of the date tool class I am about to release version 4. For more information, see ).