Skip to main content
The 2024 Developer Survey results are live! See the results

Questions tagged [getter-setter]

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.

1 vote
2 answers
57 views

How to add an ArrayList in a Superclass using Getters and Setters from a subclass

Here is the super class: public abstract class ImperialCluster implements Serializable,Clusterable { private static final long serialVersionUID = 1L; private String clusterType; ...
Tomas Gutierrez's user avatar
-1 votes
0 answers
36 views

Oneline Getter and Setter in Java inside VS Code [duplicate]

Is it possible to enable now (or in the near future) an option to get the getters and setters in one-line (just like intelliJ is doing) ? I managed to have inline hints displayed with editor....
joe's user avatar
  • 1
0 votes
1 answer
27 views

Override NSManagedObject getter/setter to modify data

I have an NSManagedObject class that stores, among other things, a JSON string that comes from a WkWebView form. The form in the web view allows the user to add images to the form; when the form is ...
Markus's user avatar
  • 2,522
-3 votes
1 answer
57 views

ReactJS - useState object loses getters when it is updated [closed]

I have a useState initialized to an object of type ExampleObject. This class has many properties (also nested) that make use of javascript's getters and setters. I use the getters all around my code ...
Rodolfo's user avatar
  • 310
-1 votes
1 answer
48 views

Some error with the @Data and some getters/setters thing in Lombok

I don't know why, but my object class Product cannot create getters/setters with Lombok. Does this make sense? This is the Product object class. package com.lab2.model; import lombok....
Le Trong Hung FPL HCM's user avatar
0 votes
1 answer
53 views

c# winforms. Problem when storing and calling controls

So I have two forms, a parent form and a child form, and a custom control. The parent form has an empty list of the custom controls and a button that calls the child form. The child form has a button ...
RyanCode_4012's user avatar
1 vote
2 answers
96 views

How to write a getter which accesses a heap-allocated member variable

Lets say I have the member: char* name; When writing a getter function to this member, is this the correct way: char* getName(){ return name; } But when we do this, now user of this class can ...
serkan ertas's user avatar
0 votes
1 answer
47 views

Mechanics of python attribute setting on class types, for use in descriptor setters

Recently, with the change of the @classmethod decorator no longer being able to wrap the @property decorator (Python >= 3.11), there has been significant interest in how to create a @classproperty ...
Mr G's user avatar
  • 268
0 votes
1 answer
52 views

Trigger a property setter when an attribute of an injected class changes in python

I have this python problem (simplified here for the sake of the example) where I have 2 classes: One child class (to be injected) and one parent class. In the parent class, I have an attribute that ...
TheNomad's user avatar
  • 345
1 vote
1 answer
150 views

What is the proper getter and setter for java atomic properties

I have an atomic boolean property in Java private AtomicBoolean endOfInputDataSet; What are the proper getter and setter of this property and what are the consequences of each choice? I can return ...
banan3'14's user avatar
  • 4,602
0 votes
1 answer
49 views

How does the Setter method work in Java in this example :

In the Setter Method "setName()", int the first line, name=this.name ; takes the value of the string "nidhi" in the second line, this.name=name; what actually happens i can't ...
HappyCoderNids's user avatar
1 vote
1 answer
74 views

New FormData(SomeForm) Not Calling Custom Getter in JavaScript

I have a custom dropdown componant. Within this component, I set a custom getter and setter shown below: Object.defineProperty(this.DropDownInputTarget, 'value', { get: function() { return ...
Jeff B's user avatar
  • 1,040
-2 votes
4 answers
189 views

C# class property with "two types"

I there any way in c# to create a property which will be basically a bool but can be set via string? What I want to achive is simple: string stringValue = "true"; object.BoolValue = ...
Jan Daliba's user avatar
0 votes
1 answer
70 views

Java universal getter/setter or pass attribute as a getter/setter argument

Is it possible to make a class getter/setter that can take any of the class attributes as an argument so as not to have to make a getter/setter pair for each attribute needed? I am new to Java For ...
spaghetticode's user avatar
0 votes
1 answer
61 views

Get and set on every property (for cookies)

I want to do cookie.c.something = "hello". That will set the document.cookie to "something=hello;". Then I can get it back again with cookie.c.something. I have already made the ...
stio's user avatar
  • 1

15 30 50 per page
1
2 3 4 5
146