So I’m trying to do an input verification for my program in java, and I’m trying to do that in this setter: But when I call it and put a wrong name, the do…while does not work and the program just continue Here’s where I call it What am I doing wrong? Answer Maybe that’s because in your catch you
Tag: setter
Using set and get methods in java
In my programming class, the teacher said we have to implement a class and use get methods but did not mention set methods in the description. Are they always used or should be used together? This is what I’ve written so far: Answer No, setters are not needed at all when implementing immutable classes/objects: Don’t provide “setter” methods — methods
Getters and setters not working as it should
I need help im working on an assignment and getters and setters are not working. so im using an action listener when add amount is clicked it should add the amount that was entered to deposit amount …
Setter methods or constructors
so far I have seen two approaches of setting a variable’s value in Java. Sometimes a constructor with arguments is used, others setter methods are used to set the value of each variable. I know that a constructor initialises an instance variable inside a class once a class is instantiated using the “new” Keyword. But when do we use constructors