Enhanced loop in java programming

writing4angels By writing4angels, 26th Nov 2010 | Follow this author | RSS Feed | Short URL http://nut.bz/pd--pwim/
Posted in Wikinut>Guides>Technology>Computer Software

Enhanced loop is supported in java from 1.5 versions and has simplified the way for loop had been used in java.

Enhanced loop in java programming

Unlike traditional java loop where the initializations and declarations happens couple of time, enhanced loop is easy to use and avoids many declarations and initializations.

Take a look at the following example:

Class EnhancedLoop

{

public static void main(String args)

{

String a={”abc”,”xyz”};

For(String x: a)

{



System.out.println(x);

}

}

}

As show here, in enhanced for loop “a” is the array reference assigned to string x on the left side and every time the loop executes each member of a is assigned to x in order.

Tags

Enhanced Loop, Enhanced Loop In Java, Java Applet, Java Enhanced Loop, Java Main Method, Java Programming, Java Script

Meet the author

author avatar writing4angels
A real lover of literature and I appreciate good works of other fellow writers who have given priceless contribution to the content on Internet.

Share this page

moderator johnnydod moderated this page.
If you have any complaints about this content, please let us know

Comments

author avatar Android Example
8th Jan 2016 (#)

very nice blog, i have also found one good link here.
<a href="http://androidexample.com/While_-_Do_While_-_For_Loop_Statements_In_Java/example.php?view=description&aid=148&article=162&mcat=2">Loop Statements In Java</a>

Reply to this comment

Add a comment
Username
Can't login?
Password