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.

2157 questions
0
votes
4 answers

Java Get and Set returning value 0 on an operation

I'm having trouble getting the value of an operation. All I get as a result is 0. I've tried many things but nothing seems to work. I'm a beginner so I'm sorry if this is something really simple. I looked around for similar problems but I couldn't…
Rene Vazquez
  • 13
  • 1
  • 4
0
votes
1 answer

Magic classes in Typescript

I have some problems with Typescript and "@botstan/Magic" library in nodejs. before we get started please read "Magic" documentation. follow lines: import Magic from "@botstan/magic"; import * as _ from "lodash"; @Magic export default class Base…
0
votes
1 answer

How do I call get method in matlab?

classdef Untitled enumeration M('monday','first day') T('tuesday','second day') end properties(SetAccess=private) name description end methods %constructor function obj = Untitled(name, description) obj.name = name …
Ninalol
  • 45
  • 7
0
votes
1 answer

Why has my float value from getFloat() become 0.0?

I'm new on java is there any problem with my coding about float? because it became 0.0 and I didn't understand float much can you explain it? It happen on getFloat This program to calculate cone volume public class Cone_Volume { private int ri, hi,…
Miseba
  • 11
  • 2
0
votes
1 answer

Unable to resolve errors in maven project eclipse photon

I have imported an existing manven project into my eclipse new workspace which I downloaded from github. On maven install I get a BUILD SUCCESS but the red cross on the project never goes. This issue has been raised previously : link1, link2 Most of…
Eswar
  • 1,201
  • 19
  • 45
0
votes
2 answers

Java - Adding specific indexes from arraylist using getters

new java developer here so please bear with me. I'm currently creating a basic program which will take user inputs and store them in an array list. There are some support logs in an array list and I am trying to calculate the sum of total hours…
AmsKumar
  • 93
  • 1
  • 10
0
votes
2 answers

Class Fields in VB.NET can be encapsulated without the Getter & Setter?

In a VB.NET I noticed that I'm able to create a property directly by using the Property keyword followed by the property name and the datatype without the need for the getter and setter method while I can't do this in C#! Nevertheless, this property…
0
votes
1 answer

Getters Not Working Properly

I am working on a report file to call multiple methods to function on an external Reporting file. Below is my report.java file and the getter elements do not seem to be working. These elements are generateReport and isServerActive. This is what I am…
0
votes
3 answers

get associated getter/setter of field (member variable)

I have a Field f of some class MyClass and I want to retrieve the associated getter/setter, if it exists. How do I do this? I checked the methods of Field, but there is not even one that returns a Method. I played around with BeanInfo retrieved by…
Kjara
  • 2,504
  • 15
  • 42
0
votes
0 answers

Setters and Getters on node attributes

I'm trying to set a getter on some node so when its id/className/src attributes will be called my function will be called also, my code is: let RealClass = node.className; Object.defineProperty(node, "className", { get(value) { //some…
avi dahan
  • 539
  • 3
  • 19
0
votes
1 answer

How to read a TimeStamp datetime2(2) from a Sql database into Groovy

I am trying to read a TimeStamp datetime2(2) from a SQL server database which is in the format '2017-05-05 07:00:15.04'. I get a formatting error in my groovy while executing. i Have used as follows: private DateTime Time_TimeStamp; .... //…
user9630935
  • 349
  • 1
  • 4
  • 18
0
votes
2 answers

Why is setting a String in class not possible but getting the String possible?

My problem includes an Activity and a RecyclerViewAdapter. I want to pass the Stringvalue of an Uri from my Activity to my RecyclerViewAdapter. For passing I am using this Getter and Setter class: updateDataAdapter.java public class…
Jakob
  • 1,858
  • 2
  • 15
  • 26
0
votes
2 answers

How to pass variable to another class java

I have FXMLDocumentController.java and i wanna to send name(textfill) to anoterclass public class FXMLDocumentController implements Initializable { @FXML private Label label; @FXML private Button button; @FXML private TextField name; private String…
user10155386
0
votes
3 answers

C# property getters and setters with perameters

I'm creating a matrix class so I already have a public double this[int row, col] but I'd also want to easily set and get a particular row or column in a similar fashion. I currently have: public virtual Vector GetRow(int row) { return…
Raxmo
  • 57
  • 5
0
votes
0 answers

Defining logic in class constructor to modify instance variable based on other constructor arguments in python

i have a python class in which i have few arguments sent to constructor as below. class Test(object): def __init__(self, a, b): self.a = a if b<10: self.a = a*2 I know that, constructors are just meant to initialize…
rawwar
  • 4,834
  • 9
  • 32
  • 57