Home > database >  get return type without execution of method
get return type without execution of method

Time:01-04

i have tried to make some web research, but i haven't find any answer, i would like to get immediately the return statement without the execution of the method that give it. (it run before)

 public static int totalIncome (String [][]field) {
      
      int sum = 0;  
      sum  = chairPrice (field); // here get the number without run the method
          return sum;
          
  }

i can't post all the code of the project i am working, i am stuck to get all the ticket sold and i was thinking this was a good way, but isn't working because it run the method again. any idea how to do this is welcome. i remove some method beuse it did't let me post it all, i can't even post the method chairPrice. StackOverflow say there is too much code in my post, i tried to share all the code by codeshare, https://codeshare.io/kmRQWV

CodePudding user response:

There is no way, in Java, to say "I already called this method, give me the value that was returned last time." You must explicitly store a variable somewhere to hold the value.

That said, from your code, it doesn't look like you can't call chairPrice because it's already been called before, but because some other state has changed. You will need to figure out the problem in your logic.

  • Related