No enclosing instance of type testTry is accessible. Must qualify the allocation...之解决方法
生活随笔
收集整理的這篇文章主要介紹了
No enclosing instance of type testTry is accessible. Must qualify the allocation...之解决方法
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
報錯原因:
????????因為在做異常處理測試時,我寫的內部類是動態的,即public class開頭無static關鍵字修飾,而測試主程序是靜態的main方法;在Java中,類中的靜態方法不能直接調用動態方法。只有將某個內部類修飾為靜態類,才可以在靜態類中調用帶類的成員變量和成員方法:
解決方法:
????????將動態內部類改為靜態(public static class)即可:
總結
以上是生活随笔為你收集整理的No enclosing instance of type testTry is accessible. Must qualify the allocation...之解决方法的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: yang模型中rpc_RPC校正方法研究
- 下一篇: [转]优秀程序员的45个习惯