Java Loop

Loop
Loops provide efficient way for repeating a piece of code as many times as required. Java has three ways to use the loop control structures and these are:

For Loop: The ‘For-Loop’ is used when we know in advance how many iteration is required
While Loop: The while loop is used when we do not know in advance the number of iterations required so each time before entering the loop the condition is checked and if it is true then the loop get executed
Do-While Loop: The do-while loop is always executed at least once and then the condition is checked at the end of the loop. Developer has to avoid using the do-while loop since it marks major bottleneck in the code.

Since loop repeats the piece of code therefore it gives more cause for performance and need to be very careful during the implementation

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s