当前页面: 开发资料首页 → J2SE 专题 → exception问题 
exception问题 
摘要: exception问题  
需要在初始时对final型的a赋值
public class test{
  static final int a;
  static{
   a=methed();
  }
}
问题是这个method需要一个error handle,
但是如果我用
  static{
   try{
     a=methed();
   }catch(Exception e){}
  }
的话,a就无法在初始时赋值了,请问怎么处理?
public class aa
{
static final int a;
static int b;
static
{
try
{
b = methed();
}
catch (Exception e)
{
                       //your codes here
}
finally
{
a = b;
}
}
static int methed()
{
return 1;
}
}