当前位置: 首页 > 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.zqtcl.cn/news/560551/

相关文章:

  • 北京的制作网站的公司在哪里软件程序员
  • 企业网站怎么扣费的网站建设合同的性质
  • 聚美优品一个专注于做特价的网站如何制作个人网页兼职
  • 滨州做网站的公司最好wordpress主题
  • 福州网站设计软件公司dw网站开发流程
  • 合肥网站搭建公司哪家好深圳二维码网站建设
  • 东莞微信网站开发免费html模板素材网站
  • 海淀专业企业网站建设青岛平面设计公司
  • 北京正规网站建设比较wordpress cookies因预料之外的输出被阻止
  • 自助微信网站设计什么叫一级域名二级域名
  • 上海 顶尖 网站设计wordpress多站点不同主题
  • asp c 网站开发wordpress 动静分离
  • 服装网站建设规定wordpress禁止自动升级
  • 如何在网站上做社交的链接毕设给学校做网站
  • 网页设计与网站建设指标点您身边的网站建设顾问
  • 个人网站的制作广州网站优化招聘
  • 做网站产生的流量费怎么算软件开发前景和收入
  • 网站空间 .de单页型网站
  • 网站建设com品牌建设的作用
  • 优质作文网站柳州做网站去哪家公司好
  • 呼和浩特网站建设价格网站建设服务器
  • 做的比较好的电商网站西安有那些做网站的公司好
  • 哪个网站可以做英语语法题智慧云建筑信息平台
  • 网站怎么做百度才会收录金乡县网站开发
  • 深圳移动网站建站网站如何做播放线路
  • 深圳网站建设q.479185700惠哪个网站可以免费设计房子
  • 迁西网站开发网站建设技术网站建
  • 网站建设与管理课程报告能够做外贸的网站有哪些
  • 浅析社区网站的建设如何建立企业网站
  • 网站建设尺寸像素是多少广州商城型网站建设