Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

use boolean value for loop

Tags:

java

for-loop

So technically a boolean is True (1) or False(0)...how can I use a boolean in a loop?

so if FYEProcessing is False, run this loop one time, if FYEProcessing is true, run it twice:

for (Integer i=0; i<FYEProcessing; ++i){
   CreatePaymentRecords(TermDates, FYEProcessing);      
}
like image 941
Leslie Avatar asked Dec 29 '25 19:12

Leslie


1 Answers

So technically a boolean is True (1) or False(0)

This is not true in Java. You cannot use an integer in place of a boolean expression in a conditional, i.e. if (1) {...} is not legal.

You are better of just doing this sequentially rather than attempting to use some sort of looping strategy to avoid having two lines which call CreatePaymentRecords()

CreatePaymentRecords(TermDates, FYEProcessing);  
if (FYEProcessing) {
    //run again
    CreatePaymentRecords(TermDates, FYEProcessing);  
}
like image 93
matt b Avatar answered Jan 01 '26 08:01

matt b



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!