For Loop - Looping Code

OliverE

Power member.
Reputation
0
For Loop
[video=youtube]http://www.youtube.com/watch?v=bFnEbIPDi1w[/video][/CENTER]


The for loop is a way of looping your code a set amount of times.

Steps
  • Create a new project & class.
  • Replace any code with the my Java code below.
  • Run and view the output in the console
[java]
public class forloop {
public static void main (String [] args)
{
int i;

for(i=0; i<5; i++)
{
System.out.println(i);
}
}
}[/java]
Note: The for loop runs in a specific order. If your getting an answer that is one less than expected, please read below.
[java]for(1st; 2nd; 4th)
{
//3rd
}[/java]


Thats another Java tutorial for you.
No tasks for this time.
Let me know if you have any issues.
Thanks
 
Didnt realise I had tutorials already waiting for videos xD
Bumped this video from 7th to 12th xD
 
Back
Top