Professional Documents
Culture Documents
Default is optional:
Instead of default the result variable num in
initialized to 31.
S is three.
(controlling data s in string form)
Nested switch statement:
ITERATION STATEMENT:
do-while:
body of the loop executed at least once
For loop:
Another example
5 prime.
Loop is controlled by interaction of two variable
USING COMMA:
Loop run forever- no condition under which it will
terminate. Some programs such as operating
system command processors require infinite loop.
Infinite loops are just loops with special
termination requirements. The syntax streamlined and prevents boundary
errors.
“For-each” style loop or Enhanced loop: Iteration variable is “read-only” as it relates to the
for-each style loop is designed to cycle through a underlying array. can’t change the contents of the
collection of objects, such as an array, in strictly array by assigning the iteration
sequential fashion, from start to finish.
output
..........
.........
........
.......
......
for loop to search an unsorted array for a value
.....
(examining each element in sequence) if the array ....
were sorted, a binary search could be used, which ...
would require a different style loop. It is used for ..
computing an average, finding the minimum or .
maximum of a set, looking for duplicates
JUMP STATEMENTS:
LOCAL VARIABLE TYPE INFERENCE IN A FOR
Break, continue and return
LOOP.
These statements transfer control to another part
The type of a local variable to be inferred from
of your program.(also through exception handling)
the type of its initializer.a
Break:
Force immediate termination of a loop, bypassing
the conditional expression and any remaining
code in the body of the loop. program
control resumes at the next statement following
the loop.
Outerloop run for three times, inner loop
shoud have run for 100 times due to break
statement it terminate when j=10.