在kotlin实现接口的时候小白可能会遇到以下异常:
抛出异常:kotlin.NotImplementedError: An operation is not implemented: not implemented
在实现接口的时候IDE会自动为我们添加上:
TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
“TODO("not implemented")”这句代码,这句代码在运行的时候会抛出以上异常,这样做的好处是促使我们去实现接口方法或者手动删掉这句代码。
解决这个异常的方法就是删掉这行代码
本文介绍在使用Kotlin实现接口时遇到的一个常见异常——NotImplementedError,并提供了解决方案。通常IDE会在未实现的方法中自动插入TODO注释,运行时会触发此异常,提醒开发者完成接口方法。
1822

被折叠的 条评论
为什么被折叠?



