Public mutator methods in object-oriented programming, responsible for changing and returning the value of private class members, thus keeping with the principle of encapsulation.
Questions tagged [getter-setter]
2157 questions
0
votes
0 answers
Spring, fill setters of object from getters other object
I could not quickly find a solution, I decided to do it myself and share it.
Spring, fill setters of object from getters other object
Standart Java-based code:
public class Mediator{
public static Contact getFullContact(){
Contact…

Andrew H.
- 1
- 1
0
votes
1 answer
How can I get my variable to change the value?
I need to set this variables click to a different number. However when I reuse ServicesForm(), click is always 0 even after adding 1. How can I set a variable for the entire class?
Getter/Setter:
Class ServicesVariables
Private click As Integer…

LegendOfZelda
- 63
- 7
0
votes
1 answer
My professor skiped a variable in the setter, did he make a mistake in the code he wrote?
Our professor has given us exercises, and given us the code how they should've been done, so there's something I don't get, I have sent him an email a week ago, but he didn't reply, so I'm turning to stackoverflow, where I don't get is in the…

Anil
- 3
- 2
0
votes
0 answers
JavaFX ClassCastException while trying to populate TableView with SQLite DB data
I have populated a TableView in a previous project but I have never done this with different datatypes. I am trying to populate 3 columns with data in my 'Concentrates' Table but I keep getting ClassCastException errors and my getters and setters do…

disco420
- 35
- 1
- 7
0
votes
2 answers
main class wont recognize class?
I have this code written:
public static void main(String[] args) {
Scanner s = new Scanner(System.in);
Liber l = new Liber();// and here, the second 'Liber', it's telling me to "create constructor 'Liber()' in tipetnumerike.Liber"
Whilst…

alison
- 13
- 3
0
votes
0 answers
Get information from already created object
I will try to be as clear as possible. I have an object ButtonData which have setters and getters. In class InfoController I create an object and, set data to ButtonData. I want to get this data in another class Controllerand use already stored data…

Boxify
- 23
- 4
0
votes
0 answers
How to make slicing list @property to call its setter in python
How to assign values to a slice of some @property of a class, which happens to be a list or numpy.ndarray, so that it's setter is called? Now it seems that assignment to a slice calls only getter. I cannot understand how a slice is handled under the…

Cos_ma
- 75
- 9
0
votes
1 answer
In android how do I convert my setter value to a string?
In my activity I have sharedReview.setPhoneNumberofUserFromDB(obj.getString("username"));
It sets the value to a string from my DB and then I get that value in my adapter for use in my recyclerView, which is working ok.
In my activity how can I…

CHarris
- 2,693
- 8
- 45
- 71
0
votes
0 answers
How to declare 2D Arrays in Java and Implement them (Procedural Programming)
I'm struggling to understand 2D arrays and my exam is in 2 days, I've tried myself but I just can't get my head around it so this is basically my last resort and I really need help understanding them.
An example question which would require you to…

abidm98
- 9
- 2
0
votes
2 answers
How can I change the property value in subclass within swift?
According to swift language guide's Inheritance chapter, I tried to code compuputed peoperty in subclass. When I set newValue to the property of the class's instance, the setter seemed to work, while the property value did not convert into the…

astost
- 11
- 4
0
votes
2 answers
Access variable through classes in objective-c
In my project, my first view is a loging one, and I would like to get the username for example into others classes.
I don't really know how I can get it in other classes, I searched in stackoverflow and didn't find (I tried several things but it…

ciwol
- 355
- 2
- 12
0
votes
4 answers
Getter returning NULL c#
When accessing the property using the getter i'm getting a NULL. I've changed it to public to test if everything else is working and yeah nothing else is wrong.
HTProvince Class
public string provinceCode;
public string ProvinceCode
{
get;…
user6785796
0
votes
3 answers
Accessing variables from another classes with setter and getter JAVA
This is a very simple example of my project which is a lot more bigger in scale.
Tasks:
The password will be set at the setpassword method.
The getpassword method will return the password.
The password is called at sendmail class in order to be…

Klayd Pro
- 1
- 1
- 2
- 7
0
votes
0 answers
Python: unable to access generated functions in a python class
I have a class that contains a nested dictionary that I want to make getters and setters for. I use a depth first search to generate the functions and add them to the class's __dict__ attribute, but when I try to call any of the generated functions,…

Clayton Ramstedt
- 115
- 1
- 7
0
votes
1 answer
Make js object loop redundant
I'm the tester of a JS api. The user will call our methods directly.
Example:
function funcWeGiveToUser(objFromUsers){
// here we will loop over user provided object
}
The dev wrote the funcWeGiveToUser in such a way that we're blindly looping…

Adelin
- 7,809
- 5
- 37
- 65