![](https://images2017.cnblogs.com/blog/725061/201711/725061-20171101180735732-1775570452.png)
import java.util.Scanner;
public class test {
public static void main(String args[])
{ int a,b,c;
Scanner s=new Scanner(System.in);
a=s.nextInt();
b=s.nextInt();
c=s.nextInt();
test t=new test();
try{
t.triangle(a,b,c);
}
catch(IllegalArgumentException e ){
e.printStackTrace();
e.getMessage();
}
}
void triangle(int a,int b,int c){
if((a+b)<c||(a+c)<b||(b+c)<a)
throw new IllegalArgumentException("不能构成三角形");
else System.out.println(a+" "+b+" "+c);
}
}
![](https://images2017.cnblogs.com/blog/725061/201711/725061-20171101180748920-42522346.png)
import java.util.InputMismatchException;
import java.util.Scanner;
import java.util.regex.Matcher;
public class test2 {
public static void main(String args[]){
Scanner s=new Scanner(System.in);
int[] shuzu=new int[5];
int i=0,shuzhi=s.nextInt();
try{
while(shuzhi!=0){
shuzu[i]=shuzhi;
shuzhi=s.nextInt();
i++;
}
}
catch(InputMismatchException e){
System.out.println("请输入整数");
}
catch(ArrayIndexOutOfBoundsException e){
System.out.println("请输入5个整数");
}
finally{
System.out.println("欢迎使用本程序");
}
}
}