double balance = loanAmount,principal,interest;
Can someone explain about this variable and multi assignments? How it is possible that "balance" can have 3 assignments (loanAmount, principal, and interest)?
This statement follows the form
<type> <identifier> [ '=' <expression> ] [',' <identifier> [ '=' <expression> ] ...]
So you're doing this:
double
with the name balance
and assign the value of loanAmount
to it;double
with the name principal
;double
with the name interest
.See JLS § 14.4 for more details.
I wouldn't advise this kind of declaration, but it is valid.