public class Demo1 {
public String get(String s){
if (s.equals("1")){
return "1";
}
return "hello";
}
public static void main(String[] args) {
System.out.println(new Demo1().get("1"));
}
}
------解决思路----------------------
public class test {
public int a(){
int i=3;
try {
i=i/0;
return 1;
} catch (Exception e) {
// TODO: handle exception
try {
switch (i) {
case 0:
System.out.println(2);
return 2;
case 1:
System.out.println(3);
return 3;
case 2:
System.out.println(4);
return 4;
case 3:
System.out.println(5);
return 5;
case Integer.MAX_VALUE:
System.out.println(6);
return 6;
case Integer.MIN_VALUE:
System.out.println(7);
return 7;
default:
System.out.println(8);
return 8;
}
} catch (Exception e2) {
// TODO: handle exception
System.out.println(9);
return 9;
}
finally{
System.out.println(10);
return 10;
}
}
finally{
System.out.println(11);
return 11;
}
}
public static void main(String[] args) {
test t=new test();
System.out.println(t.a());
}
}
输出
随便写的,有错误,请批评指正。