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

易迈互联网站建设怎么样深圳正规seo

易迈互联网站建设怎么样,深圳正规seo,福建龙岩天宫山,汕头网络推广seo渠道java 批量处理 示例Here, we will analyse some exception handling codes, to better understand the concepts. 在这里#xff0c;我们将分析一些异常处理代码 #xff0c;以更好地理解这些概念。 Try to find the errors in the following code, if any 尝试在以下代码中…java 批量处理 示例Here, we will analyse some exception handling codes, to better understand the concepts. 在这里我们将分析一些异常处理代码 以更好地理解这些概念。 Try to find the errors in the following code, if any 尝试在以下代码中查找错误(如果有) Code 1: 代码1 public class prog { public static void main(String arg[]) { try { int a 10, b 0; int c a / b; } catch (RuntimeException e) { System.out.println(e.getMessage()); } catch (ArithmeticException e) { System.out.println(e.getMessage()); } } } Output 输出量 /prog.java:8: error: exception ArithmeticException has already been caught} catch (ArithmeticException e) {^ 1 error Explanation: 说明 When using multiple catch blocks, we have to make sure that the exceptions are caught in the reverse order of inheritance of the exceptions. This means that most specific exceptions must be caught before the most general exceptions. ArithmeticException must be caught before the RuntimeException. 当使用多个catch块时我们必须确保以与异常继承相反的顺序捕获异常。 这意味着必须在最一般的异常之前捕获最具体的异常。 必须在RuntimeException之前捕获ArithmeticException 。 Code 2: 代码2 public class prog { public static void main(String arg[]) { try { throw new Integer(25); } catch (Exception e) { System.out.println(e.getMessage()); } } } Output 输出量 /prog.java:4: error: incompatible types: Integer cannot be converted to Throwablethrow new Integer(25);^ Note: /prog.java uses or overrides a deprecated API. Note: Recompile with -Xlint:deprecation for details. 1 error Explanation: 说明 We can only throw objects of Throwable class or classes that inherit this class. Integer class does not extend the Throwable class and thus, we cannot throw objects of Integer class. Similarly the statement throw 25 is erroneous. Unlike C, where we can throw objects, in Java we can only throw those objects that inherit the Throwable class. 我们只能抛出Throwable类或继承该类的类的对象。 Integer类不会扩展Throwable类因此我们不能抛出Integer类的对象。 类似地 “ throw 25”的陈述是错误的 。 与C 可以抛出对象不同在Java中我们只能抛出那些继承Throwable类的对象。 Code 3: 代码3 public class prog { public static void main(String arg[]) { err ob1 new err(); ob1.func(); } } class err { void func() { try { System.out.println(Inside try); } finally { System.out.println(Inside finally); } } } Output 输出量 Inside try Inside finally Explanation: 说明 It is not necessary that we attach a catch block to a try block. Try statement can be associated with a finally statement directly. 不必将catch块附加到try块。 try语句可以直接与finally语句关联。 Code 4: 代码4 import java.io.*; public class prog { public static void main(String arg[]) { err ob1 new err(); ob1.func(); } } class err { void func() throws IOException { try { System.out.println(Inside try); } catch (Exception e) { System.out.println(Inside catch); } finally { System.out.println(Inside finally); } } } Output 输出量 /prog.java:6: error: unreported exception IOException; must be caught or declared to be thrownob1.func();^ 1 error Explanation: 说明 If a function is said to throw any checked exception, then that checked exception must be caught by the caller. The statement void func() throws IOException clearly states that the function can throw an IOException that must be handled by the caller. The error can be corrected by enclosing the ob1.func() statement in a try-catch block. 如果说一个函数抛出了任何已检查的异常则调用者必须捕获该已检查的异常。 声明“ void func()throws IOException ”清楚地表明该函数可以抛出IOException必须由调用者处理。 可以通过在try-catch块中包含 ob1.func() 语句来纠正该错误。 Code 5: 代码5 import java.io.*; public class prog { public static void main(String arg[]) { err ob1 new err(); ob1.func(); } } class err { void func() throws RuntimeException { try { System.out.println(Inside try); try { int[] a new int[10]; int c 10; a[c] 0; } } catch (Exception e) { System.out.println(Inside catch); } } } Output 输出量 /prog.java:14: error: try without catch, finally or resource declarationstry {^ 1 error Explanation: 说明 Every try block must have an associated catch or finally block. In the code, the inner try block does not have an associated catch or finally block. 每个try块必须具有关联的catch或finally块。 在代码中内部try块没有关联的catch或finally块。 翻译自: https://www.includehelp.com/java/examples-on-exceptional-handing-in-java.aspxjava 批量处理 示例
http://www.pierceye.com/news/560551/

相关文章:

  • 免费网站建设合同书山西网站建设企业
  • 网站建设空间什么意思学做网站什么语言合适
  • 网站开发的形式有( )友情链接英文
  • 帝国网站管理系统前台免费photoshop下载
  • 深圳一百讯网站建设wordpress汉化包
  • 建设一个班级网站的具体步骤自己的网站源代码一片空白
  • 初创公司 建网站wordpress 模板获取数据库
  • 怎么在网站做推广不要钱六安网约车平台
  • 申晨推荐的营销网站做卖挖掘机的网站
  • 网站广告牌制作教程来几个好看的网站
  • php企业网站源码蓝色印度喜欢用什么框架做外贸网站
  • 网站建设教程最新资讯wordpress说说伪静态
  • 长春建站程序网络营销推广方法脑24金手指效率高
  • 专门做房地产设计的图片网站在安徽省住房和城乡建设厅网站
  • 怎样制作图片网站广告制作公司电话
  • 电子商城网站开发教程湖北网站建设路
  • 广告公司网站模版快速seo关键词优化技巧
  • whois哪个网站好WordPress判断文章形式
  • 昆明网站建设排名网站推广营销策划方案
  • 深圳网站建设中心手机端网站搭建
  • 提取卡密网站怎么做怎么更换网站的域名
  • 网站开发接单网站站内推广方案
  • 网站建设网站建什么网站做二手货车
  • 如何做淘宝客的网站网站建设 源代码
  • 建设部网站 造价全世界足球排名前十位
  • 有机农产品网站开发方案新闻资讯平台有哪些
  • wap网站建设哪家好酒店网络推广怎么做
  • 专业做电脑系统下载网站聚名网域名怎么备案
  • 赚钱的网站做任务南通优化网站价格
  • 个人能进行网站开发孟村网 网站