BEGINNER’S GUIDE TO MOBILE APP DEVELOPMENT IN ANDRIOD STUDIO
comment line in Java. The compiler ignores anything written next to //. Comments are used for increasing the readability of the code. The output of the do–while program is shown below:
Figure 4.23. do–while loop example in Java Note: There are two important keywords that are used to further control loops: break and continue statements. These commands are usually used together with an if statement. The break command breaks the loop; it means the program quits the current loop before the loop condition expires. On the other hand, continue command makes the loop continue with the next iteration
4.6. Methods in Java Methods are subroutines that are used for performing an operation. Methods are similar to functions in other programming languages but the difference is that methods are always associated with classes and objects. 74