Not all languages support a TO keyword. It is commonly found in languages such as BASIC and is used to define a closed range of values. In the context of a FOR loop, it is used to define the closed range of values for the loop's control variable.
For example:
FOR x=1 TO 10
PRINT x
NEXT x
Here, the FOR statement defines a control variable named x in the closed range [1:10]. Note that a closed range is an inclusive range, thus the body of this loop will execute for all values x where 1<=x<=10. Initially, x is assigned the lower bound of the range, 1.
At the start of each iteration, x must be evaluated to ensure that it is in the valid range of values. If it is in the range, execution passes to the first statement in the loop, where we print the value of x. When we reach the NEXT x statement, x is incremented (adding 1 to the value of x) and control passes to the start of loop where x is re-evaluated.
In this case, our loop will print the values 1, 2, 3, 4, 5, 6, 7, 8, 9 and 10.
When x is 10, the NEXT x statement will increment x to 11 and pass control back to the start of the loop where x is re-evaluated. At this point x is no longer in the valid range of values so execution passes to the statement immediately following the NEXT x statement, thus terminating the loop.
A FOR statement can also include a STEP value, which determines the amount we increment the control variable at the end of each iteration. The default STEP value is 1. However, if we wish our loop to count backwards, we must provide a STEP value of -1:
FOR x=10 TO 1 STEP -1
PRINT x
NEXT x
Output: 10, 9, 8, 7, 6, 5, 4, 3, 2 and 1.
We can also STEP by values other than 1 and -1.
FOR x=1 TO 10 STEP 2
PRINT x
NEXT x
Output: 1, 3, 5, 7 and 9.
If you meant 'what can be used' then it is statement break.
break
what is the use of new keyword in awt programming
No such thing as if-loop. if-else statement is not a loop.
Because you have to repeat something. (Or you can use while-loop, too.)
If you meant 'what can be used' then it is statement break.
break
If a loop begins with "while" then the test is made at the top of the loop, and the block is executed only when the expression (in parentheses) evaluates to true; if the loop begins with "do" then the block is executed at least once, and the "while" test is made at the bottom of the loop, to determine whether it is executed again. In C/C++ the test at the end is a "while" keyword. However, in some other languages, the test at the end may use an "until" keyword, so that the block is repeated only when the condition is false and the loop exits when it is true.
what is the use of new keyword in awt programming
You can use a for loop whenever you can use a while loop; it's the same.
The keyword "break" will immediately terminate the enclosing loop. Otherwise using conditions in the loop will terminate the loop once the condition becomes false. eg int i = 0; int b =0; for(i ; i < 3; i ++){ b++; } Will increment i and b on each iteration. The loop will terminate when i >= 3 (when the condition i < 3 becomes false).
Delete keyword
No such thing as if-loop. if-else statement is not a loop.
Yes. while loop consist of only condition statement to make for loop look as while loop we can use syntax shown below: for(;condition;) eg: for(;i<=n;)
we cannot use the staic keyword inside the method... But we can use the final keyword inside the method....
Because you have to repeat something. (Or you can use while-loop, too.)
"Java This keyword" is a reference to the current object, it is very helpful when you need to refer an instance of a particular Object from its available methods or using it's constructor, also "this" keyword helps us to avoid naming conflicts.The following are different ways to use java this keyword1) Using with instance variable2) Using with Constructor3) Pass / Return current instanceUsing with instance variableUsing this keyword inside a method or constructor it will use instance variable instead of local variable, in the absence of this keyword it will use local variableUsing with instance variableUsing this keyword inside a method or constructor it will use instance variable instead of local variable, in the absence of this keyword it will use local variableUsing with ConstructorUsing this keyword inside constructor like followingthis("Sony", 20); it will call the constructor having same parameter