我如何知道空指针异常的起源? [英] How can I know where a Null Pointer Exception originated?

查看:15
本文介绍了我如何知道空指针异常的起源?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在制作 Blackberry 应用程序时遇到了问题.我找到了一些制作教程的人,该教程完成了我对我的尝试.我复制了教程应用程序的代码以尝试重新创建它,只是为了查看它的运行情况.结果:空指针异常.

I had a problem making a Blackberry app. I found some guy who made a tutorial which did what I attempted with mine. I copied the code of the tutorial's app to try and recreate it, just to see it in action. The result: Null Pointer Exception.

我想知道是什么触发了这个.我该怎么办?

I want to know what is triggering this. How can I?

推荐答案

如果捕获 Throwable 而不是捕获 Exception 或 Exception 的任何子类,则可以查看堆栈跟踪.例如

You can view the stacktrace if you catch Throwable instead of catching Exception or any subclass of Exception. e.g.

try
{
   //some code
}
catch(Throwable t)
{
    //Will automatically show a stacktrace in eclipse.  
    //I believe on a real device it will put the stacktrace in the eventlog.  
}

这篇关于我如何知道空指针异常的起源?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆