/************************************************** * Author: Morrison * Date: 31 Mar 202020 **************************************************/ import java.util.ArrayList; public class Repeat { public static void main(String[] args) { //C style for loop System.out.println(""); for(int k = 0; k < 10; k++) { System.out.printf("\n", k, k*k); } System.out.println("
%s%s
"); ArrayList al = new ArrayList<>(); al.add("cat"); al.add("dog"); al.add("elephant"); al.add("fox"); al.add("giraffe"); System.out.println(al); for(int k = 0; k < al.size(); k++) // for k in range(len(al)): { // print(al[k]) System.out.println(al.get(k)); } //error: out of scopeSystem.out.println(k); //Collections for loop for(String item: al) // for item in al: { System.out.println(item); // print(item) } int n = 10; while(n >= 0) { System.out.println(n); n--; } System.out.println("blastoff!!!"); } }