This week's book giveaway is in the OCMJEA forum.
We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line!
See this thread for details.
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


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
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: 14117
    
  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
 
Don't get me started about those stupid light bulbs.
 
subject: effect of private static final objects in java?