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
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.
[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
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]
{
//3rd
}[/java]
Thats another Java tutorial for you.
No tasks for this time.
Let me know if you have any issues.
Thanks
No tasks for this time.
Let me know if you have any issues.
Thanks