• Post Reply Bookmark Topic Watch Topic
  • New Topic

Difference: static final members& final static members  RSS feed

 
Akshayan Venkatesh
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is the Difference between static final members and final static members

example :

static final int x = 10;
final static int x = 10;

please explain me. in advance.
 
Campbell Ritchie
Marshal
Posts: 55786
164
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There is no difference. But "final static" is the usual format.
 
Shrek Shrek
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
both are same. U can use the keyword static and final in any order
 
Peter Chase
Ranch Hand
Posts: 1970
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Campbell Ritchie:
But "final static" is the usual format.


The Java Language Specification canonical order is "static final".


The access modifiers are placed in canonical order as specified by "The Java Language Specification". This is public , protected or private first, and then other modifiers in the following order: abstract , static , final , synchronized native .
 
Campbell Ritchie
Marshal
Posts: 55786
164
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, you are right. Sorry for writing "final static."
 
Anupam Sinha
Ranch Hand
Posts: 1090
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I find static final to be more natural.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!