Question: IN JAVA (a) Transform the enhanced for loop in the following fragment of code into a while loop: int r = 0, k = 0;
IN JAVA
(a) Transform the enhanced for loop in the following fragment of code into a while loop: int r = 0, k = 0; for (int i : a) { if (i < k) r = i; k = i; } System.out.println("result: " + r);
(b) Suppose that a is declared as follows: int[] a = { 3, 0, 2, 1, 2 }; What is printed out as a result of executing this fragment of code? Show details of workings.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
