Menu
Menu
DaniWeb
Log In
Sign Up
Read
Contribute
Meet
Search
Search
About 1,000 results for
setter
- Page 1
Setter getter ..? what is this and what it does ?
Programming
Software Development
14 Years Ago
by Xufyan
Setter
getter ..? what is this and what it does ? i searched over google but didn't find the suitable answer...!
Re: Setter getter ..? what is this and what it does ?
Programming
Software Development
14 Years Ago
by Xufyan
… the name ?? and how do we set the name using
setter
, should i have to create an object before setting up… is set using parametrized constructors } }[/CODE] now how to use
setter
to set the name in above program?? Why you've… parametrized constructor if you want to set the name using
setter
? if we can use parametrized constructor then why do we…
Re: Setter getter ..? what is this and what it does ?
Programming
Software Development
14 Years Ago
by Dean_Grobler
…it is, getter methods get variables, and
setter
methods set variables. Say for instance you…; } public String getfirstName() { return firstName; } } [/CODE]
Setter
methods then would set the Name variable, so you would…be the code in your Contact class for the
setter
method: [CODE] public void setfirstName(String firstName)…
Re: Setter getter ..? what is this and what it does ?
Programming
Software Development
14 Years Ago
by kramerd
… other stuff contact1.setName("John"); // example of calling
setter
// do some other stuff String name = contact1.getName(); // example of…/he can't "write" new info with a
setter
. Hope that helps.
Re: Setter getter ..? what is this and what it does ?
Programming
Software Development
14 Years Ago
by Xufyan
… other stuff contact1.setName("John"); // example of calling
setter
// do some other stuff String name = contact1.getName(); // example of…/he can't "write" new info with a
setter
. Hope that helps.[/QUOTE] why you have over written the…
Re: Setter getter ..? what is this and what it does ?
Programming
Software Development
14 Years Ago
by Xufyan
…, so you can set any number of things in one
setter
eg [CODE]person.setEmployment(String employer, float salary);[/CODE] A… understand how to return those values using get from one
setter
?
Re: Setter getter ..? what is this and what it does ?
Programming
Software Development
14 Years Ago
by ~s.o.s~
[quote]how could i create a single getter and
setter
for these two ? [/quote] You typically don't; if you … wouldn't be called a "getter" or "
setter
" in normal Java sense. Also, if you did that…
Re: Setter getter ..? what is this and what it does ?
Programming
Software Development
14 Years Ago
by vaibhav1983
getter and
setter
methods are specifications of Java MDB standards. The instance varibales are private. So to change their values and retreive their values we specify getter and
setter
methods.
Re: Setter getter ..? what is this and what it does ?
Programming
Software Development
14 Years Ago
by Xufyan
… formed".[/QUOTE] Ok i understand why do we use
setter
, but you didn't answer my other questions
Re: Setter getter ..? what is this and what it does ?
Programming
Software Development
14 Years Ago
by Xufyan
What should i've to do if i want to create one get and one set method for more than one values ??? Example: [CODE]String Name; int Age;[/CODE] how could i create a single getter and
setter
for these two ?
Re: Setter getter ..? what is this and what it does ?
Programming
Software Development
14 Years Ago
by JamesCherrill
…, so you can set any number of things in one
setter
eg [CODE]person.setEmployment(String employer, float salary);[/CODE] A…
Re: Setter getter ..? what is this and what it does ?
Programming
Software Development
14 Years Ago
by Xufyan
… two instance variable rollno and name then i created a
setter
to set the values OK ? but i didn't understand…
Re: Setter getter ..? what is this and what it does ?
Programming
Software Development
14 Years Ago
by imtiyaz41
The
setter
and getter methods are the accessor and mutator method which …
Re: Setter returns something?
Programming
Software Development
13 Years Ago
by stultuske
… a value, if you write it like that, but a
setter
is ment to 'set' data, not to 'get' it. a… sure you handle this exception correctly everywhere you call this
setter
[Code=Java] // an age may only be between 0 and… be aware of any logic within the
setter
, so, unless everyone who uses this
setter
immediately after checks the value using the…
Setter returns something?
Programming
Software Development
13 Years Ago
by Joey_Brown
Hello. What is the best way [an a correct one] to check a value, lets say I need a user input in a certain range. Could I place this check inside a
setter
method? My
setter
would than be a boolean return type instead of void? Are there some "laws" against making the
setter
return something? Thank you for any info. Joey
Re: Setter returns something?
Programming
Software Development
13 Years Ago
by adarshcu
Yes setting the value of a variable using a
setter
is the best way . But then you do not return …a boolean value.
Setter
should not return a value. It is against programming conventions…
Re: Setter returns something?
Programming
Software Development
13 Years Ago
by hfx642
It is VERY common for "
setter
" type functions (methods) in database programming. Not so much in other languages.
Re: Setter returns something?
Programming
Software Development
13 Years Ago
by JeffGrigg
For "method chaining" / "fluent interface" there's a pattern, including Builder Pattern, for having
setter
methods return 'this'.
Re: Setter getter ..? what is this and what it does ?
Programming
Software Development
14 Years Ago
by kramerd
The purpose of getters & setters is to hide the implementation of a datatype from the "user" (usually another programmer). If I write a class, I usually need a way to allow you to set up the data the way you want, but I don't necessarily want you to know about the datatypes I'm using to store your data. So I give you get & set …
Re: Setter getter ..? what is this and what it does ?
Programming
Software Development
14 Years Ago
by JamesCherrill
[QUOTE]i searched over google but didn't find the suitable answer...! [/QUOTE] The technical OO terminology is "accessors and mutators" - googling these will give you lots of good info. Here's a good article to start with: [url]http://java.about.com/od/workingwithobjects/a/accessormutator.htm[/url]
Re: Setter getter ..? what is this and what it does ?
Programming
Software Development
14 Years Ago
by Xufyan
[QUOTE=JamesCherrill;1352715]The technical OO terminology is "accessors and mutators" - googling these will give you lots of good info. Here's a good article to start with: [url]http://java.about.com/od/workingwithobjects/a/accessormutator.htm[/url][/QUOTE] It helped me alot..! thanks alot ! i didn't new that they are called …
Re: Setter getter ..? what is this and what it does ?
Programming
Software Development
14 Years Ago
by JamesCherrill
Name isn't a very realistic example, but how about: Bank account - interest rate is set when account is created, but may be changed at any time later Product in shop - price ditto
Re: Setter getter ..? what is this and what it does ?
Programming
Software Development
14 Years Ago
by Xufyan
can you give example with the code ?>?
Re: Setter getter ..? what is this and what it does ?
Programming
Software Development
14 Years Ago
by JamesCherrill
You already have samples of code, just use your own imagination to apply them to the other examples.
Re: Setter getter ..? what is this and what it does ?
Programming
Software Development
14 Years Ago
by JamesCherrill
That's an example of what I just said. The get method returns rollno and name by putting them into a new class and returning that class contining both values.
Re: Setter getter ..? what is this and what it does ?
Programming
Software Development
14 Years Ago
by kramerd
[code]public Student getValues(){[/code] The line above is the declaration of a public function called getValues which takes no arguments and returns an object of type Student. [code] Student s = new Student(); // object in the same class ? :confused: [/code] The line above creates a local object variable called s of type Student inside the …
Re: Setter getter ..? what is this and what it does ?
Programming
Software Development
14 Years Ago
by Xufyan
[QUOTE=JamesCherrill;1355064]That's an example of what I just said. The get method returns rollno and name by putting them into a new class and returning that class contining both values.[/QUOTE] can you please exlain this, ? why uses the class name in the method?? [iCODE] public Student getValues(){[/iCODE]
Re: Setter getter ..? what is this and what it does ?
Programming
Software Development
14 Years Ago
by Xufyan
[QUOTE=kramerd;1355602][code]public Student getValues(){[/code] The line above is the declaration of a public function called getValues which takes no arguments and returns an object of type Student. [code] Student s = new Student(); // object in the same class ? :confused: [/code] The line above creates a local object variable called s …
Re: Setter getter ..? what is this and what it does ?
Programming
Software Development
14 Years Ago
by JamesCherrill
In java they are all methods. A method that returns a value based (only) on its parameters can also be called a function. In practice many people use these terms casually. You can treat them as being the same unless you want to get very technical about programming theory.
Re: Constructors vs setter methods.
Programming
Software Development
12 Years Ago
by harinath_2007
…doesn't make difference whether you use constructor or
setter
methods. If you have a constructor that accepts arguements… initialize in the constructor itself. Otherwise you can use
setter
methods instead. Either way , both approaches results same.…second method , we are setting the title value using
Setter
method. In the first case, if you want …
1
2
3
17
Next
Last
Search
Search
Forums
Forum Index
Hardware/Software
Recommended Topics
Programming
Recommended Topics
Digital Media
Recommended Topics
Community Center
Recommended Topics
Latest Content
Newest Topics
Latest Topics
Latest Posts
Latest Comments
Top Tags
Topics Feed
Social
Top Members
Meet People
Community Functions
DaniWeb Premium
Newsletter Archive
Markdown Syntax
Community Rules
Developer APIs
Connect API
Forum API Docs
Tools
SEO Backlink Checker
Legal
Terms of Service
Privacy Policy
FAQ
About Us
Advertise
Contact Us
© 2025 DaniWeb® LLC