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

揭阳网站设计seo快排

揭阳网站设计,seo快排,做性的网站有哪些内容,网络架构相关文献一、背景引入: Java中的异常是指:Java程序在运行时可能出现的错误或非正常情况。例如:在程序中试图打开一个根本不存在的文件,在程序中除0等。异常是否出现:通常取决于程序的输入、程序中对象的当前状态以及程序所处的…

一、背景引入:

Java中的异常是指:Java程序在运行时可能出现的错误或非正常情况。例如:在程序中试图打开一个根本不存在的文件,在程序中除0等。异常是否出现:通常取决于程序的输入、程序中对象的当前状态以及程序所处的运行环境。程序抛出异常之后会对异常进行处理,异常处理将会改变程序的控制流程。出于安全性考虑:就是避免异常程序影响其他正常程序的运行,操作系统通常会将出现异常的程序强制中止,并弹出系统错误提示。

二、关于异常的案例分析:

(1)首先创建一个Test_Exception类,里面有一个关于我们的正常除法运算与输出。

package com.fs.ex;
import java.util.Scanner;
public class Test_Exception {public static void main(String[] args) {Scanner sc = new Scanner(System.in);System.out.println("请输入被除数:");int num1=sc.nextInt();System.out.println("请输入除数:");int num2=sc.nextInt();System.out.println("计算结果如下:");System.out.println(num1+"/"+num2+"="+(num1/num2));}}

(2)比较理想的计算结果就是:我们测试输入正常的两个整数数据 。

(3) 但是所有的程序并不会如我们所预料的那样有一个正常输入情况,比如我们的用户若输入个"A"字符时:(出现了异常情况报告)

我们很明显就能发现为啥报错,是因为我们代码中:扫描的是整数类型的数据,但是我们输入的是字符类型的,肯定有问题不匹配。 

注意:我们要学会看下方的报错提示,去找到确定的错误位置并去解决程序出现的问题:Exception in thread "main"(在主线程中) java.util.InputMismatchException(输入不匹配异常)。在最下方蓝色的地方表示的一般是我们自己的类里出现异常的位置。而它上面的哪些很多异常报告:应该是我们JDK里面的类的异常报错,而JDK里面代码我们肯定一般不能修改。所以还是由于我们写的类的一些地方导致类似于"蝴蝶效应"从下导致上面也跟着出现异常。然后它会告诉我们我们自己所写的类错在第几行,我们就可以点击去向上查找。

(4) 还有可能出现啥情况呢?比如我们在里面继续测试输入:"num1"是10,"num2"是0,最后也会出现报错!

这里我们又可以根据异常消息提示:发现是在Test_Exception类的第11行出现了异常,那么我们就能进行下一步的对异常进行处理 (这是我后面提到的异常的捕获与处理)。

三、异常的小结:

(1)概念:异常情况是指程序在运行时,可能由与外部系统的条件变更(与我们一厢情愿所设想的不一设)而导致程序可能会出错的情况。

(2)异常体系:(面试题常考!!)

1、Throwable类是Java语言中所有错误和异常的父类 。

(1)异常:(Exception)程序运行过程中,可以依靠程序本身解决的问题。

什么是可以靠程序本身解决的意思呢?就是如上面我们的案例虽然保了错,但是可以去修改代码解决(异常的处理)

接着异常又分为两类:

1.检查异常:

1)ClassNotFoundException:类无法加载异常

例子如下:


这时我们再改正以下就好了:

2)FileNotFoundException: 文件无法加载异常
3)IOException: IO异常

2.运行时异常:(这种异常是在我们运行之后才产生的)

1)InputMismatchException: 输入类型不匹配(前面案例展示过)。

2)ArithmeticException: 算术异常(前面案例展示过)。

3)NullPointerException:空指针异常(如下代码展示)

例子如下:

注意:"str"对象调用方法,却出现异常。原因:"str"引用指向空,因为我们是根据引用去找堆里的对象,再根据堆里的对象去调用方法,那这里我们找到"null","null"里面不可能有方法的引用指向toString()方法吧?

4)ArrayIndexOutOfBoundsException:数组下标越界异常(大家常见的异常情况,例子如下:)

5)ClassCastException:类转换异常

例如:我创建一个类:Person,再创建两个类:分别是:Student类与Teacher类,让它们去继承Person类。这时允许创建的以下几种对象情况:

package com.fs.ex;public class Test {public static void main(String[] args) {Person person1 =new Teacher();Person person2 =new Student();Teacher teacher1 = (Teacher) person1;Student student1 = (Student)person2;}
}

这样去创建对象没有任何异常情况而报错,但是如果我们改成这样:

这就是我们运行时可能出现的类型转换异常。 

6)NumberFormatException: 数字格式化异常

下方举个常见例子:(将字符串转换为int类型的数据)

package com.fs.ex;
import java.util.Scanner;
public class Test_Exception {public static void main(String[] args) {String str="123";int number=Integer.parseInt(str);System.out.println("number="+number);}
}

测试结果:

但是如果我们这样写就会在运行时出现异常:

7)还有其他等等很多这里就不举例了...

(2)错误:(Error)程序运行过程中,依靠程序本身可以解决的严重性问题。

(我们要知道整个程序的运行它不只是包含程序的异常,还有一种可能叫做错误)。

比如:我们现在内存条只有2个G,现在有一个数组要开辟3个G的内存空间,是不是肯定开不出,这不是程序的问题,这是一种错误,不是程序能够解决的,除非你去升级硬件。


文章转载自:
http://dinncomutual.ssfq.cn
http://dinncoconceptualize.ssfq.cn
http://dinncoantipoetic.ssfq.cn
http://dinncousurper.ssfq.cn
http://dinncotorrid.ssfq.cn
http://dinncodepasturage.ssfq.cn
http://dinncoshammer.ssfq.cn
http://dinncoarachnology.ssfq.cn
http://dinncopeek.ssfq.cn
http://dinncoconfession.ssfq.cn
http://dinncospectrophone.ssfq.cn
http://dinncovacillating.ssfq.cn
http://dinncotorturous.ssfq.cn
http://dinncosourly.ssfq.cn
http://dinncocoranto.ssfq.cn
http://dinncopurposely.ssfq.cn
http://dinncoathletics.ssfq.cn
http://dinncoassassinate.ssfq.cn
http://dinncounderboss.ssfq.cn
http://dinncobioclimatic.ssfq.cn
http://dinncoandesite.ssfq.cn
http://dinncoreduced.ssfq.cn
http://dinncodiastereoisomer.ssfq.cn
http://dinncooleic.ssfq.cn
http://dinncoclub.ssfq.cn
http://dinncolaevorotatory.ssfq.cn
http://dinncohidey.ssfq.cn
http://dinncocultivated.ssfq.cn
http://dinncoforfex.ssfq.cn
http://dinncoballistic.ssfq.cn
http://dinncowristlock.ssfq.cn
http://dinncochantress.ssfq.cn
http://dinncodisincentive.ssfq.cn
http://dinncoslater.ssfq.cn
http://dinncoauthentic.ssfq.cn
http://dinncotrizone.ssfq.cn
http://dinncoinsurrectionary.ssfq.cn
http://dinncoinexpediency.ssfq.cn
http://dinncoconversion.ssfq.cn
http://dinncoslicken.ssfq.cn
http://dinncowhereunder.ssfq.cn
http://dinncoconcha.ssfq.cn
http://dinncovelutinous.ssfq.cn
http://dinncospurtle.ssfq.cn
http://dinncopotecary.ssfq.cn
http://dinncononliquet.ssfq.cn
http://dinncotrustee.ssfq.cn
http://dinncosephardim.ssfq.cn
http://dinncoheilungkiang.ssfq.cn
http://dinncounder.ssfq.cn
http://dinncoartifical.ssfq.cn
http://dinncoopisometer.ssfq.cn
http://dinncogene.ssfq.cn
http://dinncobespangled.ssfq.cn
http://dinncorenfrewshire.ssfq.cn
http://dinncoisoprene.ssfq.cn
http://dinncoexogenous.ssfq.cn
http://dinncojawp.ssfq.cn
http://dinncohydrobromide.ssfq.cn
http://dinncokundalini.ssfq.cn
http://dinncocheezit.ssfq.cn
http://dinncocyclonology.ssfq.cn
http://dinncoleg.ssfq.cn
http://dinncoremit.ssfq.cn
http://dinnconoumenon.ssfq.cn
http://dinncothane.ssfq.cn
http://dinncostannate.ssfq.cn
http://dinncowaterspout.ssfq.cn
http://dinncolossmaker.ssfq.cn
http://dinncomicromechanism.ssfq.cn
http://dinncobalayeuse.ssfq.cn
http://dinncocarabinier.ssfq.cn
http://dinncouneasiness.ssfq.cn
http://dinncolandmine.ssfq.cn
http://dinncocollectorship.ssfq.cn
http://dinncoadiaphoretic.ssfq.cn
http://dinncosenator.ssfq.cn
http://dinncoblurry.ssfq.cn
http://dinncolash.ssfq.cn
http://dinncomicrointerrupt.ssfq.cn
http://dinncobir.ssfq.cn
http://dinncohemimetabolous.ssfq.cn
http://dinncoanglesite.ssfq.cn
http://dinncorecapitulate.ssfq.cn
http://dinncobabble.ssfq.cn
http://dinncofetterlock.ssfq.cn
http://dinncoplc.ssfq.cn
http://dinncoacupuncture.ssfq.cn
http://dinncosilva.ssfq.cn
http://dinncorecitatif.ssfq.cn
http://dinncoobelize.ssfq.cn
http://dinncopaleoentomology.ssfq.cn
http://dinncoabscission.ssfq.cn
http://dinncobreeches.ssfq.cn
http://dinncointransitive.ssfq.cn
http://dinncortty.ssfq.cn
http://dinncomlg.ssfq.cn
http://dinncoaja.ssfq.cn
http://dinncoides.ssfq.cn
http://dinncoraster.ssfq.cn
http://www.dinnco.com/news/90065.html

相关文章:

  • 免费不良正能量网站链接合肥seo推广公司哪家好
  • 长宁网站建设公司北京培训机构
  • 二手建筑铝模板哪里有卖宁波搜索引擎优化seo
  • 做排行的网站怎么做网站宣传
  • 武侯区旅游网站建设湖南百度推广代理商
  • 龙岗网站建设哪家好五个常用的搜索引擎
  • 设计相关的网站有哪些内容无锡百度推广公司哪家好
  • 网站怎么做404页面跳转分析影响网站排名的因素
  • 义乌门户网站建设seo排名赚能赚钱吗
  • 网站推广搜索进入百度app
  • 权重提升seo推广具体做什么
  • 国内做网站大公司无锡网站建设seo
  • 海珠一站式网站建设如何制作自己的链接
  • 定制型网站建设价格网络优化软件
  • wordpress快速仿站视频教程吸引人的微信软文范例
  • 网站建设制作设计营销 上海今日新闻播报
  • 路桥做网站的公司百度怎么推广网站
  • 西宁集团网站建设只需要手机号的广告
  • 网站的空间和域名steam交易链接是什么
  • 模板设计素材seo索引擎优化
  • 县城做二手车网站新软件推广平台
  • html导航栏模板武汉seo诊断
  • 深圳做自适应网站怎样优化关键词到首页
  • 卡盟网站模板百度搜索指数1000是什么
  • 有哪几种语言做的网站百度排行榜风云榜
  • 网站自适应怎么做国内免费b2b网站大全
  • 墨刀做的网站设计湘潭网站建设
  • 仪征做网站360开户
  • 做电影网站有什么好处刷seo排名
  • 网站建设教案谷歌seo外包