setter : Java Glossary
home S words local find no local find frame, full screen Google search web for topic jump to footer translate with Babelfish 2007-09-09 by Roedy Green ©1996-2008 Canadian Mind Products
Go to : punctuation 0-9 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z (all)
setter
An instance method that simple set a value in the object instance. e.g.
The advantage of a setters is you can later add code to compress, validate or modify the value, without changing any of the client code. You can also add side effects like logging or recomputing something else or updating a display.

Modern IDEs such as IntelliJ Idea will compose a set of getters and setters for you, given just the private instance variables.

Normally within a class you don’t usually use the setters; you go direct to the underlying instance variables, though sometimes it makes sense from a maintenance point of view to channel through setters. Within a package or from outside, you would nearly always go through setters rather than going to directly to public instance variables.

You can also write setters for static variables.


CMP_homejump to top
CMP logo
feedback Please email your feedback for publication, errors, omissions, broken/redirected link reports
and suggestions to improve this page to Roedy Green : feedback email
made with CSS
HTML Checked!
ICRA ratings logo
mindprod.com IP:[65.110.21.43]
Your face IP:[38.103.63.18] The information on this page is for non-military use only.
You are visitor number 1,084. Military use includes use by defence contractors.
You can get a fresh copy of this page from: or possibly from your local J: drive (Java virtual drive/Mindprod website mirror)
http://mindprod.com/jgloss/setter.html J:\mindprod\jgloss\setter.html