title: Why should I compare the balance with BigDecimal.ONE before a transaction in Java?
body: <p>I'm looking at a tutorial about a financial transaction from an account to another and before transfering the amount from an account to another they do these 2 comparations:</p>
  
  <pre><code>fromAccount.getCurrentBalance().compareTo(BigDecimal.ONE) == 1
                  &amp;&amp; fromAccount.getCurrentBalance().compareTo(amount) == 1
  </code></pre>
  
  <p>I understand that they do the second comparation to compare the balance with the amount, but what I don't understand is why they compare the balance with BigDecimal.ONE. Can somebody explain?</p>
  
  <p>I don't understand for what is this comparation:</p>
  
  <pre><code>fromAccount.getCurrentBalance().compareTo(BigDecimal.ONE)
  </code></pre>
  
  <p>This is the code:</p>
  
  <pre><code>if(fromAccount.getCurrentBalance().compareTo(BigDecimal.ONE) == 1
          &amp;&amp; fromAccount.getCurrentBalance().compareTo(amount) == 1
  ){
      fromAccount.setCurrentBalance(fromAccount.getCurrentBalance().subtract(amount));
      accountRepository.save(fromAccount);
      toAccount.setCurrentBalance(toAccount.getCurrentBalance().add(amount));
      accountRepository.save(toAccount);
      Transaction transaction = transactionRepository.save(new Transaction(0L,fromAccountNumber,amount,new Timestamp(System.currentTimeMillis())));
      return transaction;
  }
  return null;
  </code></pre>