• Post Reply Bookmark Topic Watch Topic
  • New Topic

Java Set and Get  RSS feed

 
bob reilly
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I understand the concept of get and set methods in java. Here's my problem - in one java application - we have a set that appears to work properly. Subsequently we added a new set method (vendor API ) in the same method. This set does not appear to work. When we check the application for the expected output - it isn't there. No error is thrown - nothing. Trace does not show any issues.

Can you have two different set methods updating the same object consecutively? Is there something you need to do between each set.

Any comments / suggestions / URLs are appreciated. Thank you.
 
Nico Van Brandt
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you please post the code?
 
Greg Brannon
Bartender
Posts: 563
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I agree with Nico, some code would be nice, but I'll address your comments about get(ters) and set(ters).

getters and setters are also called access (or accessor) and mutator methods, respectively. There's nothing magic or special about them. They are methods with a specific purpose - most methods have a specific purpose - to return or modify a class' variables. Just as you can have multiple methods that do the same thing by giving them different signatures, you can have multiple methods that return or modify the same variable.

You asked, can "two different set methods updat(e) the same object consecutively?" Just so we're talking the same language, consecutively means "one after the other without interruption." Yes, you can have multiple methods that do the same thing which can be called one after the other. That should be true with any and all methods.

To help further, we'll need to see your native method, the vendor method, and an explanation why you think one works and the other doesn't.
 
bob reilly
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Nico / Greg,
Thank you for responding. I'll post some of the code. Just so you know after speaking with another party I think you've done as much as you can do. Main reason is this is a vendor API which we do not have the underlying code.

Here's a cutout of the problem area (all in the same method):
----------------------------------------------------------------------------------------

---------------
There's not to much to add. All the code here was traced. Your prior comments confirmed my thinking that you can have two consecutive 'set' methods. Like I said before - the 'set' method syntax is not available to me - so what is causing the issue - don't know. I've reviewed this code - there's nothing wrong with it. If you see something let me know but I don't think you will.

Thank you both for responding.
 
Nico Van Brandt
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The code looks like it should work.

But it's not all about correct code. Maybe:
- the OvrStartDate can be set by another function call?
- the maxDate is not taken by the setter because its doing an check before assigning the value?

The fact is you cannot know for sure unless you see the implementation of the setter.
 
Greg Brannon
Bartender
Posts: 563
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And verify that the value of maxdate makes sense, since that's the argument of the API method call and (I assume) your only basis for thinking that the call is not working.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!