• Home
  • About
  • Work Portfolio
Blue Orange Green Pink Purple

Java – foreach equivalent

Posted in Java. on Saturday, January 30th, 2010 by Daniel Noormohamed
Jan 30

Java 5 introduced what is sometimes called a “for each” statement that accesses each successive element of an array, List, or Set without the bookkeeping associated with iterators or indexing.


String[] names = {"Michael Maus", "Mini Maus"};

for (String s : names) {
System.out.println(s);
}

the output results


Michael Maus
Mini Maus

Leave a Reply

You must be logged in to post a comment.

Noormohamed

  • About
    About me. Edit this in the options panel.
  • Photo Stream
  • Categories
    • CSS
    • Donate
    • Hosting
    • Java
    • jQuery
    • PL/SQL
    • VMWare
    • WordPress Plugin
  • Recent Articles
    • PL/SQL Basic Insert (no return)
    • VMWare Player on a VMWare ESX Guest
    • Java – do loop
    • Java – foreach equivalent
    • Java – while loop
    • Java – for loop
  • Archives
    • February 2010
    • January 2010
    • April 1999
  • Search






  • Home
  • About
  • Work Portfolio

© Copyright Noormohamed. All rights reserved.
Designed by FTL Wordpress Themes brought to you by Smashing Magazine

Back to Top