java中的final,const和static变量有什么区别

时间:2015-03-10 01:33:05

标签: java variables static const final

java中final,const和static变量之间的区别是什么 请用代码示例 `

1 个答案:

答案 0 :(得分:10)

class X
{
  static int s; // can be accessed as X.s without object
  final int f = 7; // can't be assigned a different value
  const int c; // doesn't compile
}