First, the demand
Recently encountered a small problem in the project, that is, from the database to take two variables, to determine whether the variables taken out is empty, the variable is not empty, if the two variables are not empty, take two variables, two variables are empty, then skip;
Ii. Solutions (two ideas available here)
1, the first way of thinking, that is, most people will think of the idea, but also my first method, directly began to judge. Look at the code:
This idea is not wrong, but for the readability and performance of the program is not very high, not recommended to use; Next, we recommend the second idea:
2, the second way of thinking, is the use of StringBuffer append mechanism to solve, will make the program readability and performance and more efficient; look directly at the code:
Java is a convenient way to take two variables that are not empty!