• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

'class level or 'static' getters and setters

 
Mathew Lee
Ranch Hand
Posts: 238
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
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
Posts: 5575
Eclipse IDE Java Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
why you want setter and getter for static members (class level members) ?what is your requirement ?
 
Mathew Lee
Ranch Hand
Posts: 238
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I just want to know about them due to curiosity. Thanks in advance
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64960
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sure, you can create them for class-level variables. What else do you need to know?
 
Sandeep Swaminathan
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic