16 - Single-Line FOR Loops in Java Programming

preview_player
Показать описание

In this lesson we will introduce the concept of a loop in java programming. We will look at the single-line "for" loop which allows us to repeat code over and over as many times as needed.
Рекомендации по теме
Комментарии
Автор

In FOR loop It is very important to understand an order execution of statements:

initialization;

condition;
statment;
iteration;

condition;
statment;
iteration;

condition;
statment;
iteration;

...and so on, until condition are true

nikop
Автор

Thank you for these videos. You’re a good teacher and your lessons are easy to comprehend.

betancourtj
Автор

i get an error when using counter++. for(counter = 1; counter <=10; counter++) i get an unending running program of 1 repeated over and over until i terminate the program. im currently using eclipse

oldaccount-jj
Автор

what about with strings instead of int? like counting all indexes of a string

jonmarsh
Автор

This is what i will do without the for loop.Code will be unnecessary long.
public class Lesson16_asde {

public static void main(String[] args) {
int counter;
counter=0;


if(counter<=3) { //condition
.initially zero
statement, displays counter is 0
again but by iteration
, copy paste
if(counter<=3) {
counter=counter;
new counter is 1
counter=counter+1;};

if(counter<=3) {
counter=counter;
new counter is 2
counter=counter+1;};

if(counter<=3) {
counter=counter;
new counter is 3
counter=counter+1;};

if(counter<=3) { //no longer true, so java will ignore this hence termination
counter=counter; // it will not progress from here

counter=counter+1;};




}

}

vonnuevon