Progressive mining of enhanced for loop; errata (1)

Source: Internet
Author: User

The original "list 4: simple equivalent code for Traversing arrays" is incorrect and should be:

Listing 4: simple equivalent code for Traversing arrays/* Creating an array */
Int [] integers = {1, 2, 3, 4 };
/* Start traversal */
For (INT variable name a = 0; variable name {
???? System. Out. println (Integers [variable name A]);/* Output "1", "2", "3", and "4" in sequence "*/
}

Thank you for your correction.

The original "Listing 6: equivalent code for traversing the collection in a simple way" is incorrect and should be:

Listing 6: simple equivalent code for Traversing collection/* Creating a collection */
String [] strings = {"A", "B", "C", "D "};
Collection stringlist = java. util. arrays. aslist (strings );
/* Start traversal */
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", and "D" in sequence "*/
}

Thanks to Bin's correction.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.