This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes 'class level or 'static' getters and setters Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

JavaRanch » Java Forums » Java » Beginning Java
Bookmark " Watch " New topic

'class level or 'static' getters and setters

Mathew Lee
Ranch Hand

Joined: Jun 08, 2009
Posts: 238
I would like to know about
'class level or 'static' getters and setters ' in java beans. What are they how and where they are used. Any links, ideas, resources, sample code highly appreciated. Thanks in advance.
Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

why you want setter and getter for static members (class level members) ?what is your requirement ?
Mathew Lee
Ranch Hand

Joined: Jun 08, 2009
Posts: 238

I just want to know about them due to curiosity. Thanks in advance
Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 63202

Sure, you can create them for class-level variables. What else do you need to know?

[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Sandeep Swaminathan
Ranch Hand

Joined: Apr 23, 2008
Posts: 52
I presume you're confused with the difference between "class level", "static" & "getter & setters".
If you declare your method to be static, then you can use the method in another class without the need of creating any instance for it.

A static variable can also be accessed in the same way.
Getter & Setters methods are basically used for private variables to be used in another class using the methods and not the variables as such.
Hope it helps!

Music is all around us. All you have to do is just LISTEN to it,
Sandeep Swaminathan
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link:
subject: 'class level or 'static' getters and setters
It's not a secret anymore!