Questions tagged as 'getters-setters'

1
answer

I can not / know how to use the Setter [closed]

I'm trying to do some testing in JAVA here and I'm having problems: Product class, with initialization and getters/setters public class Produtos { private String[] nomeItem = {"Item 1","Item 2","Item 3","Item 4","Item 5"};...
asked by 23.12.2016 / 18:42
0
answers

Should I actually use getters and setters for all public variables in classes? [duplicate]

So this subject seems very controversial but at the same time I do not see a compromise between the developers. Some say that getters and setters are 100% rule to access any variable within a class. That is, if I have 10 variables, I will...
asked by 23.05.2018 / 16:55
2
answers

Set and Get difference in object-oriented programming [duplicate]

What is the basic difference of set and get in object-oriented programming?     
asked by 11.07.2017 / 01:23
1
answer

How to split the addressing of a class in PHP?

What is the best way to split this Aluno ? <?php class Aluno{ private $nome; private $sobrenome; private $email; private $telefone; private $cep; private $rua; private $ender...
asked by 12.12.2018 / 18:25
1
answer

Why use getters and setters in classes? [duplicate]

Why do I need to encapsulate the entire class, if I as a programmer know perfectly how to use that variable. I only see need for setters and getters to work on the value of the variable, like this: void setCommand (string val) { string r...
asked by 25.06.2017 / 13:38
0
answers

How to pick the selected options in the spinner of another activity

Class I want to check the spinner place, so I can only move to another page if I have selected something, I would use the option selected in Spinner instead in another class. public static Spinner lugar; public static EditText a; @Override pro...
asked by 21.11.2018 / 20:40
0
answers

The best way to use getters and setters

I started to study programming recently and the language chosen was Python. And I'm finding it very difficult to enter the use of getters , setters and properties. In my web surfing, I found that using property is more rec...
asked by 24.03.2018 / 21:28
0
answers

Should I build a constructor with Setter? PHP [duplicate]

What is the best and safest way to build the builder? Netbeans creates direct by changing the variable, but has how to use the setter. So what is the safest and best method? For example: No setter function __construct($nome, $idade,...
asked by 07.07.2017 / 21:22
1
answer

How do I validate a value passed by the Set?

I wanted to know how I would do when adding a new value for the length and width through setLength and SetWidth, and that value goes through validation ((x > 0 & x < 20)? x: 0 ): public class Rectangle { private double length; priva...
asked by 16.05.2017 / 04:15
1
answer

PTBR (Spinner) Firebase Exception: Found conflicting getters for name: getAdapter

I am making an application where I choose a number in the spinner and write that number in Firebase. is giving the following error: detailsaboutspinnerandhowIamwritingtofirebasespinnercarrinho=(Spinner)findViewById(R.id.spinner_carrinho);//C...
asked by 20.04.2017 / 19:39