简体   繁体   中英

What is the difference between final, const and static variables in java

java中的final,const和static变量有什么区别,请使用代码示例

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
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM