Nemo
Nemo

Reputation: 91

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

What is the difference between final, const and static variables in java with code example please `

Upvotes: 3

Views: 5523

Answers (1)

Atsby
Atsby

Reputation: 2327

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
}

Upvotes: 12

Related Questions