Questions tagged [getter]

A getter is a public accessor method, used in object-oriented programming, which returns the value associated with a private member of a class.

A getter is public method, used in object-oriented programming, which returns the value associated with a private member of a class. A getter often refers to the get portion of a property. The getter method may perform other tasks such as validation, but is usually considered non-mutating.

1882 questions
0
votes
0 answers

NullPointerException with a getter on a Long but not with a BigDecimal

This is my first question after many years of using this great forum and hence the first time I didn't find an answer to my issue :( I'm getting a strange behaviour working with BigDecimal and Long: for the first one I’m not getting a…
0
votes
1 answer

MS Visual Studio C# - Can someone explain to me why my code isn't working and how I can get it to work?

I'm writing a program to conduct a search within Windows Active Directory and return the search results to another form in a listbox. This is what my getter method looks like on the main form: public List getSearchResults() { …
0
votes
1 answer

Trouble with setter method and returning getter

I'm trying to make a setter method (setAvailForAssembly) that sets the assembledstocklevel but for some reason my if conditions don't seem to be making any effect. Why this is happening? Main Class public class TestAssembledPart { public…
danielb
  • 51
  • 1
  • 6
0
votes
0 answers

How to get a specific index for a 2d vector in Haskell

I am currently trying to access an element from a 2d Vector declared as such: data Board = FullBoard Int Int :t FullBoard FullBoard :: Int -> Int -> Board (FullBoard x y) If I am correct, the two Ints Are the size of the board, in this 2d…
user1709237
0
votes
1 answer

Objective-C getter to SWIFT equivalent

I have the following getter: -(UICollectionViewFlowLayout *)verticalFlowViewLayout { if (!_verticalFlowViewLayout) { _verticalFlowViewLayout = [[UICollectionViewFlowLayout alloc]init; [_verticalFlowViewLayout…
Μήτσος
  • 221
  • 2
  • 11
0
votes
1 answer

Create a toString() method that returns the value as a formatted time String

Im at the last few steps in my homework and need some help understanding/doing the last two steps. The last two things I have to do are: Create a toString() method that returns the value as a formatted time String. Remember that values less than 10…
BerlinUnited
  • 1
  • 1
  • 3
0
votes
1 answer

How to access an objects set and get methods when it is in an ArrayList?

So I have this code here: List xmlMessageList = new ArrayList(); now XMLMessage has set and get methods in here such as setFileContent, setFileName, and setFileDirectory and these are all Strings. So how do I access those…
SupaHotFire
  • 93
  • 1
  • 2
  • 4
0
votes
5 answers

How to Return Object through getter method in Java

I have always returned single field with getter methods, I was wondering if we can return Object using getter. I have, class Student { int age String name public Student(int age,String name) { this.age=age; this.name=name; } public Student…
VedantK
  • 9,728
  • 7
  • 66
  • 71
0
votes
2 answers

How to use int from other class?

Here is my main method: public class Main { public static void main(String[] args){ Comp.give(f, s); } } And here is my other class: import java.util.Scanner; public class Comp { private void look() { Scanner iscan =…
nbray
  • 81
  • 5
0
votes
1 answer

Ruby on Rails Formatastic ovverride attribute

I want to override an attribute in my Rails Project but the problem is, that in my form (Formtastic) it still displays the database value and not the one from the getter. Do I have to write a custom getter and setter with annother name and save the…
Raighar
  • 11
  • 2
0
votes
1 answer

Using Picker View - concept of setter, getter confusion

Alright, here's my code for a simple PickerView and it's working too. @interface ViewController () @property NSArray *moods; @end @implementation ViewController -(NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView{ return…
Adnan
  • 21
  • 1
  • 6
0
votes
3 answers

yii2: using a getter from a view

I have a user_detail table CREATE TABLE `user_detail` ( `id` int(11) unsigned NOT NULL, `userID` int(11) NOT NULL, `name` varchar(20) NOT NULL, ); I want to retrieve the value of user_detail.name in main.php to display the loggedin user's…
Michel
  • 1
  • 2
0
votes
1 answer

Java getter and setter trouble in card program

I'm working on a assignment for school and I'm having an issue that for the life of me I cannot figure out. This is just a simple "Card Game" assignment where we are basically just creating a deck of cards, shuffling and dealing out a couple cards. …
NoobCoderChick
  • 617
  • 3
  • 21
  • 40
0
votes
1 answer

"Stack size exceeds" when creating custom get/set

SO I have two "name" as a property and as an parameter passed on Object.defineProperty(). If I choose to put naming convention same on as "name" for my book object as well Object.defineProperty() I am getting an error call "Stack size exceeds " on…
Megh
  • 145
  • 9
0
votes
4 answers

NullPointerException while calling getter JFileChooser

I'm getting a NullPointerException every time I call a getter. Here's the code: import java.io.File; import javax.swing.JFileChooser; import javax.swing.filechooser.FileNameExtensionFilter; public class FileChooser extends JFileChooser { private…
Jimmy
  • 189
  • 9
1 2 3
99
100