Java 实例 - 获取异常的堆栈信息

Java 教程 · 2019-02-11 10:44:00

以下实例演示了使用异常类的 printStack() 方法来获取堆栈信息:

Main.java 文件

public class Main{ public static void main (String args[]){ int array[]={20,20,40}; int num1=15,num2=10; int result=10; try{ result = num1/num2; System.out.println("The result is" +result); for(int i =5; i>=0; i--) { System.out.println("The value of array is" +array[i]); } } catch (Exception e) { e.printStackTrace(); } } }

以上代码运行输出结果为:

The result is1
java.lang.ArrayIndexOutOfBoundsException: 5
        at testapp.Main.main(Main.java:28)

点击查看所有 Java 教程 文章: https://codercto.com/courses/l/12.html

查看所有标签

The Definitive Guide to Django

The Definitive Guide to Django

Adrian Holovaty、Jacob Kaplan-Moss / Apress / 2007-12-06 / CAD 45.14

Django, the Python-based equivalent to the Ruby on Rails web development framework, is presently one of the hottest topics in web development today. In The Definitive Guide to Django: Web Development ......一起来看看 《The Definitive Guide to Django》 这本书的介绍吧!

XML 在线格式化
XML 在线格式化

在线 XML 格式化压缩工具

html转js在线工具
html转js在线工具

html转js在线工具

RGB CMYK 转换工具
RGB CMYK 转换工具

RGB CMYK 互转工具