The variable 'MyException' is declared but never used

前端 未结 6 1961
迷失自我
迷失自我 2020-12-05 09:36

I need to clear this warning :

try
{
    doSomething()
}
catch (AmbiguousMatchException MyException)
{
    doSomethingElse()
}

The complier

6条回答
  •  温柔的废话
    2020-12-05 09:49

    You declare a name for the exception, MyException, but you never do anything with it. Since it's not used, the compiler points it out.

    You can simply remove the name.

    catch(AmbiguousMatchException)
    {
       doSomethingElse();
    }
    

提交回复
热议问题