Today we went over if statements and for loops in Java. In java and c-based languages, the for loop contains an initialization, conditional, and an updating condition. Usually, a variable is altered until it doesn't satisfy the conditional statement anymore and the loop is terminated. Likewise, the if statement executes its given code if the boolean condition is satisfied. There are many caveats when it comes to boolean operators. primitives can be compared using the == operator. In contrast, objects like strings and ArrayLists can only be compared with the .equals() function that checks the contents of the object instead of the pointer to the memory of that object.
top of page
bottom of page