-
exception
- <pre name="code" class="java"></pre><br>
- <br>
- <p></p>
- <pre></pre>
- <pre name="code" class="java">package Exception;
- import java.util.*;
- public class Exception {
- void aa(int a,int b, int c)throws IllegalArgumentException {
- int []array = new int[]{a,b,c};
- Arrays.sort(array);
- if(array[0]+array[1]>array[2]&&array[2]-array[0]<array[1])
- System.out.println("可以成为一个三角形,三条边按大小分别为"+a+","+b+","+c+"");
-
- else
- throw new IllegalArgumentException("不能组成三角形");
-
- }}
- </pre><br>
- <pre name="code" class="java">package Exception;
-
- import java.util.Scanner;
-
- public class Text {
-
- public static void main(String[] args) {
-
- try {
- System.out.println("输入三角形的三条边:");
- Scanner scanner=new Scanner(System.in);
- int a,b,c;
- a=scanner.nextInt();
- b=scanner.nextInt();
- c=scanner.nextInt();
- Exception ex=new Exception();
- ex.aa(a, b, c);
- }catch(IllegalArgumentException e) {
- e.printStackTrace();
-
- }
- }
-
- }
- </pre><br>
- <img src="http://img.blog.csdn.net/20171102194856882?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvdmljdG9yX2Zh/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center" alt=""><img src="http://img.blog.csdn.net/20171102195035360?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvdmljdG9yX2Zh/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center" alt=""><br>
- <p></p>
-
-
相关阅读:
288 Node.js模块化开发:js开发弊端,模块的概念,模块成员导出的2种方式及其区别,模块成员导入
287 Node.js快速入门:Node.js 的组成,Node.js基础语法,Node.js全局对象global
286 Node开发概述,Node运行环境搭建以及安装失败解决办法
285 H5 Web Workers
使用nvm安装nodejs
函数式 UI:Web开发终于摆脱了框架的束缚
Vue渲染函数
微信小程序使用canvas实现生成海报图的功能
Vue中插槽指令
Vue之nextTick原理
-
原文地址:https://www.cnblogs.com/spsglz/p/8017917.html
Copyright © 2020-2023
润新知