Putting initialization in try will not work. Assuming that the first sentence of try throws an exception, the result is that the two lists are not initialized. This will be checked during compilation
try{} also contains a "{}", it is a program module. You initialize the data in the module. If the module is not entered during operation, then the data outside is not initialized.
If an exception occurs, the initialization cannot be successful. As long as there is a possibility that the initialization may not be successful, the editor will report an exception.
Your problem is the same as this one. Even if you are sure that you will return here, it still cannot be compiled.
Putting initialization in try will not work. Assuming that the first sentence of try throws an exception, the result is that the two lists are not initialized. This will be checked during compilation
If an exception occurs in the first sentence of the try block, listbrand will not be initialized, so a compilation error occurs
try{} also contains a "{}", it is a program module. You initialize the data in the module. If the module is not entered during operation, then the data outside is not initialized.
If an exception occurs, the initialization cannot be successful. As long as there is a possibility that the initialization may not be successful, the editor will report an exception.
Local variables within the method must be initialized before they can be used. This is checked during compilation.