• Post Reply Bookmark Topic Watch Topic
  • New Topic

A java statement getting executed multiple times outside a for / while loop  RSS feed

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am trying to execute the following method: This method takes a delivery date as one of the arguments and a list of calendar holidays as another argument. If the delivery date is present in the holiday list, I will add 1 day more to the delivery date and check again if the new delivery date is part of holiday list.

Issue is that the last 3 statements before 'return' are getting executed multiple times though there is no for or while loop. Please help to understand why they are getting invoked multiple times.
 
Bartender
Posts: 11445
18
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch.

In future, while posting code, please UseCodeTags I have added them this time for you. As you can see the tags make the code much more easier to read and understand.

Emma Johns wrote:Issue is that the last 3 statements before 'return' are getting executed multiple times though there is no for or while loop. Please help to understand why they are getting invoked multiple times.

Check out line 33 of your code. Now does that help clear up things?
 
Ranch Hand
Posts: 45
Eclipse IDE Java
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
At line 33 fetchNextWorkingDay method is called recursively
 
Emma Johns
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks All..using your inputs, I could resolve the issue.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!