static final keyword in Java

If you make a variable as final, say  final int x=2 in a class. Then as many times the object is instantiated for that class, that many times memory space will be allocated for the same in stack.

Now, as per memory management view, if we make it static with final i.e  static final x=2 , then only one copy(i.e one address space) as final x=2 will be there.

In this way, we are saving memory space.

29 विचार “static final keyword in Java&rdquo पर;

एक उत्तर दें

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / बदले )

Twitter picture

You are commenting using your Twitter account. Log Out / बदले )

Facebook photo

You are commenting using your Facebook account. Log Out / बदले )

Google+ photo

You are commenting using your Google+ account. Log Out / बदले )

Connecting to %s