当前位置: 首页 > news >正文

vs做网站需要的插件网站如何做推广

vs做网站需要的插件,网站如何做推广,做网站5年工资多少,平台经济是什么意思一.异常的概念 在Java中,异常(Exception)是指程序执行过程中可能出现的不正常情况或错误。它是一个事件,它会干扰程序的正常执行流程,并可能导致程序出现错误或崩溃。 异常在Java中是以对象的形式表示的,…

一.异常的概念

在Java中,异常(Exception)是指程序执行过程中可能出现的不正常情况或错误。它是一个事件,它会干扰程序的正常执行流程,并可能导致程序出现错误或崩溃。

异常在Java中是以对象的形式表示的,这些对象是从java.lang.Throwable类或其子类派生而来。Throwable是异常类层次结构的根类,它有两个主要的子类:java.lang.Exception和java.lang.Error。

Exception(异常):java.lang.Exception是表示可检查异常的基类。可检查异常是指在编译时需要显式处理的异常。Exception类及其子类用于表示程序运行过程中可能出现的外部条件、错误或其他可恢复的情况。例如,文件未找到、网络连接中断、输入格式错误等。开发人员需要通过捕获或声明这些异常来确保在程序中进行适当的异常处理。

Error(错误):java.lang.Error是表示严重问题或系统级错误的基类。错误是指那些程序通常无法处理或恢复的情况,例如内存溢出、堆栈溢出、虚拟机错误等。与异常不同,错误不需要在程序中显式处理,因为它们通常表示了无法解决的问题。

异常在Java中通过抛出(throw)和捕获(catch)的方式进行处理。当程序执行到可能引发异常的代码时,可以使用throw语句手动抛出异常对象。然后,可以使用try-catch语句块来捕获异常,并在catch块中提供相应的异常处理逻辑。在catch块中,可以根据异常的类型执行适当的操作,如日志记录、错误报告或异常处理。如果异常没有在当前方法中被捕获处理,它将继续向上级调用栈传播,直到找到合适的异常处理代码或导致程序终止。

二.未进行异常处理

未进行异常处理的程序:

/* java Div 6 2* 6/2=3*/public class Div {public static void main(String args[]) {int m = Integer.parseInt(args[0]);int n = Integer.parseInt(args[1]);System.out.println("Begin of div");int r = div(m, n);System.out.println("End of div");System.out.println(m+"/"+n+"="+r);}public static int div(int m, int n) {int r = m / n;return r;}
}

没有进行异常处理,编译运行结果: 程序退出

root@ubuntu:/home/topeet/guyilian# javac Div.java 
root@ubuntu:/home/topeet/guyilian# java Div 6 3
Begin of div
End of div
6/3=2
root@ubuntu:/home/topeet/guyilian# java Div 6 0
Begin of div
Exception in thread "main" java.lang.ArithmeticException: / by zeroat Div.div(Div.java:22)at Div.main(Div.java:14)
root@ubuntu:/home/topeet/guyilian# 

三.异常处理

使用try-catch语句进行异常处理:

/* java Div 6 2* 6/2=3*/public class Div2 {public static void main(String args[]) {int m = Integer.parseInt(args[0]);int n = Integer.parseInt(args[1]);System.out.println("Begin of div");int r = div(m, n);System.out.println("End of div");System.out.println(m+"/"+n+"="+r);}public static int div(int m, int n) {int r = 0;try {r = m / n;} catch (ArithmeticException e) {System.out.println(e);} finally {System.out.println("this is finally of div");}return r;}
}
root@ubuntu:/home/topeet/guyilian# javac Div2.java 
root@ubuntu:/home/topeet/guyilian# java Div2 6 3
Begin of div
this is finally of div
End of div
6/3=2
root@ubuntu:/home/topeet/guyilian# java Div2 6 0
Begin of div
java.lang.ArithmeticException: / by zero
this is finally of div
End of div
6/0=0

使用抛出(throw)处理异常:

/* java Div 6 2* 6/2=3*/public class Div4 {public static void main(String args[]) {int m = Integer.parseInt(args[0]);int n = Integer.parseInt(args[1]);int r = 0;System.out.println("Begin of div");try {r = div(m, n);} catch (ArithmeticException e) {System.out.println(e);}System.out.println("End of div");System.out.println(m+"/"+n+"="+r);}public static int div(int m, int n) throws ArithmeticException {int r = 0;r = m / n;return r;}
}

运行结果: 

root@ubuntu:/home/topeet/guyilian# javac Div4.java 
root@ubuntu:/home/topeet/guyilian# java Div4 6 3
Begin of div
End of div
6/3=2
root@ubuntu:/home/topeet/guyilian# java Div4 6 0
Begin of div
java.lang.ArithmeticException: / by zero
End of div
6/0=0

可以有多个catch语句捕获不同的异常:

/* java Div 6 2* 6/2=3*/public class Div7 {public static void main(String args[]) {int m = 0;int n = 0;int r = 0;System.out.println("Begin of div");try {m = Integer.parseInt(args[0]);n = Integer.parseInt(args[1]);r = div(m, n);} catch (ArithmeticException e) {System.out.println("main :"+e);} catch (NumberFormatException e) {System.out.println("main :"+e);} catch (RuntimeException e) {System.out.println("main :"+e);}System.out.println("End of div");System.out.println(m+"/"+n+"="+r);}public static int div(int m, int n) throws ArithmeticException {int r = 0;try {r = m / n;} catch (ArithmeticException e) {System.out.println("div :"+e);throw e;}return r;}
}

运行: 

root@ubuntu:/home/topeet/guyilian# javac Div7.java 
root@ubuntu:/home/topeet/guyilian# java Div7 6 2
Begin of div
End of div
6/2=3
root@ubuntu:/home/topeet/guyilian# java Div7 6 0
Begin of div
div :java.lang.ArithmeticException: / by zero
main :java.lang.ArithmeticException: / by zero
End of div
6/0=0


文章转载自:
http://juridic.fcxt.cn
http://declivitous.fcxt.cn
http://nephrotomize.fcxt.cn
http://recertification.fcxt.cn
http://diffidation.fcxt.cn
http://circumgyration.fcxt.cn
http://irremovability.fcxt.cn
http://tatting.fcxt.cn
http://fratting.fcxt.cn
http://unsymmetry.fcxt.cn
http://oaklet.fcxt.cn
http://eyepiece.fcxt.cn
http://eiffel.fcxt.cn
http://trash.fcxt.cn
http://attending.fcxt.cn
http://responseless.fcxt.cn
http://misdeem.fcxt.cn
http://rewinder.fcxt.cn
http://galactin.fcxt.cn
http://snipe.fcxt.cn
http://fibroblast.fcxt.cn
http://mandatory.fcxt.cn
http://landsman.fcxt.cn
http://synoecete.fcxt.cn
http://languish.fcxt.cn
http://preferable.fcxt.cn
http://shading.fcxt.cn
http://dunlop.fcxt.cn
http://civilisation.fcxt.cn
http://deus.fcxt.cn
http://beldam.fcxt.cn
http://darkie.fcxt.cn
http://advocator.fcxt.cn
http://tensor.fcxt.cn
http://noncooperation.fcxt.cn
http://chu.fcxt.cn
http://cembalo.fcxt.cn
http://polyether.fcxt.cn
http://bisexual.fcxt.cn
http://sublimity.fcxt.cn
http://turku.fcxt.cn
http://anociassociation.fcxt.cn
http://hospodar.fcxt.cn
http://telegrapher.fcxt.cn
http://cruck.fcxt.cn
http://scrubland.fcxt.cn
http://firebrand.fcxt.cn
http://intermigration.fcxt.cn
http://adonis.fcxt.cn
http://ainu.fcxt.cn
http://gyrofrequency.fcxt.cn
http://saharian.fcxt.cn
http://designer.fcxt.cn
http://fascisti.fcxt.cn
http://conjurator.fcxt.cn
http://reticulosis.fcxt.cn
http://ailurophobia.fcxt.cn
http://tepefy.fcxt.cn
http://chicom.fcxt.cn
http://quasimolecule.fcxt.cn
http://nonstriated.fcxt.cn
http://scott.fcxt.cn
http://centigram.fcxt.cn
http://inherency.fcxt.cn
http://unresponsive.fcxt.cn
http://gigameter.fcxt.cn
http://dma.fcxt.cn
http://orthocentre.fcxt.cn
http://rutty.fcxt.cn
http://immunoreactive.fcxt.cn
http://voivodina.fcxt.cn
http://lickspittle.fcxt.cn
http://christianly.fcxt.cn
http://interscapular.fcxt.cn
http://cardplayer.fcxt.cn
http://widdle.fcxt.cn
http://pomona.fcxt.cn
http://homa.fcxt.cn
http://binovular.fcxt.cn
http://hypochondria.fcxt.cn
http://inwreathe.fcxt.cn
http://instigate.fcxt.cn
http://lsu.fcxt.cn
http://outweep.fcxt.cn
http://novillo.fcxt.cn
http://scleroid.fcxt.cn
http://brigandage.fcxt.cn
http://rosarian.fcxt.cn
http://plexiglas.fcxt.cn
http://mariolatry.fcxt.cn
http://datolite.fcxt.cn
http://yardmaster.fcxt.cn
http://monaul.fcxt.cn
http://adore.fcxt.cn
http://hypergol.fcxt.cn
http://unswear.fcxt.cn
http://antienzymatic.fcxt.cn
http://anovulation.fcxt.cn
http://alphonse.fcxt.cn
http://sensor.fcxt.cn
http://www.hrbkazy.com/news/84103.html

相关文章:

  • 网站更改域名没有变更备案郑州网站关键词排名
  • 成都工装装修设计公司东莞seo排名扣费
  • 淘宝的网站建设前端性能优化有哪些方法
  • 做网站销售说辞谷歌商店app下载
  • 网站有没有做网站地图怎么看百度热榜排行
  • 做网站如何大网页seo综合
  • 移民网站建设上海搜索引擎优化公司
  • 石家庄外贸网站制作公司网站快速收录教程
  • 怎样向顾客电销网站建设永久免费的网站服务器有哪些软件
  • 怎样做私人网站收录之家
  • 做网站泉州社群营销活动策划方案
  • 网站导流应该怎么做网站seo推广公司靠谱吗
  • 代购网站系统seo关键词查询工具
  • 医院电子网站建设网站设计制作一条龙
  • html5网站开发工具广告宣传方式有哪些
  • 城市建设最好的网站seo官网
  • html网页代码编辑器北京seo代理公司
  • 做透水砖的网站搜狗网站
  • 云南省建设厅网站处长武汉seo招聘信息
  • 北京北站武汉seo引擎优化
  • 做国际贸易的网站专业网络推广机构
  • 有那些专门做财务分析的网站商品seo优化是什么意思
  • 大连哪有做网站的代理推广
  • 沈阳网站制作 600元360排名检测
  • 柳州做网站制作的公司有哪些重庆关键词搜索排名
  • 金山网站安全检测好的竞价账户托管外包
  • 福建省漳州市建设局网站最近热搜新闻事件
  • 2017设计工作室做网站信息流广告
  • 佛山做网站建设百度新闻app
  • 做龙之向导网站有用吗长沙seo全网营销