BASIC / NOTES</>↗Basic25 Sep 2009
The continue statement has two forms, the unlabeled and labeled continue statement. The first example shows you how to use the unlabeled continue statement while the second example shows you how to use the labeled continue statement. package org.kodejava.basic; public class ContinueDemo { public static void main(String[] args) { int[] numbers = {5, 11, 3, […]
BASIC / NOTES</>↗Basic23 Sep 2009
The break statement has two forms, the unlabeled and labeled break. On the example below you see the first example as the unlabeled break. This type of break statement will terminate the innermost loop such as the for, while and do-while loop. On the second example you’ll see the labeled break. We have two loops, […]
BASIC / NOTES</>↗Basic21 Sep 2009
The for loop can be used to iterate over a range of values. For instance if you want to iterate from 0 to 10 or if you want to iterate through all the items of an array. Below you’ll see two forms of a for loop. The first one is the general form of a […]
BASIC / NOTES</>↗Basic21 Sep 2009
There is also a do-while loop in the Java programming language. Instead of evaluating the expression at the beginning like the while loop does the do-while loop evaluates its expression at the end of the loop. Due to this the loop executes at least once during the program execution. package org.kodejava.basic; public class DoWhileDemo { […]
BASIC / NOTES</>↗Basic19 Sep 2009
The code below demonstrate how to use the while loop statement. The while statement will check if its expression evaluates to true and execute the while statement block. The program below will execute while the countDown value is bigger or equals to zero. package org.kodejava.basic; public class WhileDemo { public static void main(String[] args) { […]
BASIC / NOTES</>↗Basic19 Sep 2009
The program below demonstrate how to use the switch statement. The switch statement can work with the byte, short, int and char primitive data types and the corresponding wrappers of these data type such as Byte, Short, Integer and Character. It also work with enumerated types, refer to the following example: How do I use […]