File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes effect of private static final objects in java? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "effect of private static final objects in java?" Watch "effect of private static final objects in java?" New topic
Author

effect of private static final objects in java?

Vinney Shanmugam
Ranch Hand

Joined: Aug 27, 2008
Posts: 104
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

Joined: Jan 28, 2008
Posts: 5575

it is a constant which is encapsulated
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14114
    
  16

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:


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: effect of private static final objects in java?