package testexception;
public class Exception
{
// TODO Auto-generated constructor stub
public void tset(String nn) throws Exception{
String [] name={"ss","dd","vv"};
for(int i=0;i<name.length;i++)
{
if(name[i]!=nn)
{
throw new Exception();
}
}
}
}
测试类:
package testexception;
public class Test {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
Exception en=new Exception();
try{
en.tset("k");
}catch(Exception){
System.out.println("ttt");
}
}
}
就这么多了!