File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

effect of private static final objects in java?

 
Vinney Shanmugam
Ranch Hand
Posts: 104
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I want to know what will be the effect of delcaring an object as

private static final object.


What is the use of declaring an object of class as private static final?
 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Java Windows XP
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
it is a constant which is encapsulated
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Pie
Posts: 15150
31
Android IntelliJ IDE Java Scala Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Creating a private static final object as in line 3 of your code doesn't do anything special to class a. Class a still has a public, no-args constructor (the one that the compiler automatically generates when you don't specify a constructor yourself).

So inside a method in class b, you can still do this:

  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic