-
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>
-
-
相关阅读:
壳的编写(1)-- 简介与搭建框架
Writing Your Own Packer
中断门
记一次:Windows的Socket编程学习和分析过程
封装调用包含界面的MFC dll
编译vtk8.1.1 + 在vs2017中配置开发环境
迁移通知
基于CAN总线的汽车诊断协议UDS(上位机开发驱动篇)
基于CAN总线的汽车诊断协议UDS(ECU底层模块移植开发)
浅谈jQuery,老司机带你jQuery入门到精通
-
原文地址:https://www.cnblogs.com/spsglz/p/8017917.html
Copyright © 2020-2023
润新知