BASIC / CATATAN</>↗Basic29 Sep 2009
The remainder or modulus operator (%) let you get the remainder of a division of two numbers. This operator can be used to obtain a reminder of an integer or floating point types. package org.kodejava.basic; public class RemainderOperatorDemo { public static void main(String[] args) { int a = 10; double b = 49; // The […]
BASIC / CATATAN</>↗Basic26 Sep 2009
The ternary operator or conditional operator can be use as a short version of the if-then-else statement. When you have a simple if-then-else statement in your code that return a value you might use the ternary operator, it can make your code easier to read. The ternary operator is written using the symbol of ?: […]
BASIC / CATATAN</>↗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 / CATATAN</>↗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 / CATATAN</>↗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 / CATATAN</>↗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 { […]