"Gradually excavation enhanced for loop" errata (1)

zhaozj2021-02-16  120

Original "Listing 4: The equivalent code" of the simple way to traverse the array is incorrect, should be:

Listing 4: Equivalent code for traversing an array

/ * Establish an array * /

Int [] integers = {1, 2, 3, 4};

/ * Start traversing * /

for

(INT variable name = 0; variable name

???? system.out.println

Integers [variable name]); / * Output "1", "2", "3", "4" * /

}

Thanks to Wang's finger.

Original "Listing 6: The equivalent code" of the simple way to traverse Collection "is incorrect, should be:

Listing 6: Equivalent code for traversing Collection

/ * Create a collection * /

String [] strings = {"a", "b", "c", "d"};

Collection stringlist = java.util.Arays.ASLIST (STRINGS);

/ * Start traversing * /

for

(Iterator Variable Name B = List.iterator (); Variable Name B.hasnext ();) {

????

Object str = variable name B.Next ();

???? system.out.println (STR); / * Output "A", "B", "C", "D" * /

}

Thanks BIN's finger.

转载请注明原文地址:https://www.9cbs.com/read-8962.html

New Post(0)