do while: starts executing contents of the loop before looking at the condition. therefore, execution shall run at least for once even if condition doesn't math.
e.g:
and
while: looks for the condition at the very first before executing the content.
e.g:
this one won't go inside the loop since the condition doesn't match.
e.g:
int x=11;this one will execute 1 time before it goes down to look for the condition, after that it will stop.
do{
System.out.println("human being VS being human");
x++;
}while(x<10)
and
while: looks for the condition at the very first before executing the content.
e.g:
int x=11;
while(x<10){
System.out.println("human being VS being human");
x++;
};
this one won't go inside the loop since the condition doesn't match.
No comments:
Post a Comment