Question: *Java Programming* This exercise using the three methods to demonstrate Kangaroo hopping (for loop; for each; and Iterator style). You can start with the following
*Java Programming*
This exercise using the three methods to demonstrate Kangaroo hopping (for loop; for each; and Iterator style). You can start with the following code snippets:
import java.util.*;
class Kangaroo {
private int kangarooNum;
public Kangaroo(int i) {
kangarooNum = i;
}
public void hop() {
System.out.println("Kangaroo " + kangarooNum + " hops");
}
}
public class KangarooHooper{
public static void main(String[] args) {
ArrayList
// the rest of your codes here.
/
} // end of main()
} // end of KangarooHooper
Your results display should look like this
+++++++++++ hop in for loop
Kangaroo 0 hops
Kangaroo 1 hops
Kangaroo 2 hops
Kangaroo 3 hops
Kangaroo 4 hops
----------- hop in foreach loop
Kangaroo 0 hops
Kangaroo 1 hops
Kangaroo 2 hops
Kangaroo 3 hops
Kangaroo 4 hops
*********** hop in Iterator style
Kangaroo 0 hops
Kangaroo 1 hops
Kangaroo 2 hops
Kangaroo 3 hops
Kangaroo 4 hops
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
