站内搜索: 请输入搜索关键词

当前页面: 开发资料首页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;
}
}


↑返回目录
前一篇: 关于多态的一个小问题
后一篇: java如何取得7天前的系统时间?