java - 这个地方为什么报未初始化这个错?try里面已经初始化了呀?
PHPz
PHPz 2017-04-18 09:56:06
0
6
426

报这个错,我知道让第一步初始化为null就可以了,就是不知道为什么
try里面已经初始化了呀,为什么还报这个错
The local variable listbrand may not have been initialized

PHPz
PHPz

学习是最好的投资!

reply all(6)
洪涛
int getValue(){
    if(true)
        return 1;
}

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

Ty80

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.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template