简体   繁体   English

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

[英]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
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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