Testing blog page 1
March 27, 2012
Ok, so java code help and things here. I will try to help with any questions I can with basic java.
First, loops.
If loop: if(initialisition; loop conditions; increment/decrement) {
(commands to be done);
}
This checks the loop before it does any code, so can be exected 0 times.
for(condition) {
(commands to be done);
}
Does basically the same as the if loop, but one must declare the variable they use in the condition outside the loop, and increment in the commands to be done.
The while loop
while(condition) {
(commands to be done);
}
again, the variable must be declared outside the loop, the increment must be done inside the loop. Very similar to the for loop.
The do whle loop
do {
(commands to be done);
}
while(condition)
The do while loop checks the condition after execution. In the long run, the difference is effectively that it always runs at least once, unlike the other loops.
while(condition)
First, loops.
If loop: if(initialisition; loop conditions; increment/decrement) {
(commands to be done);
}
This checks the loop before it does any code, so can be exected 0 times.
for(condition) {
(commands to be done);
}
Does basically the same as the if loop, but one must declare the variable they use in the condition outside the loop, and increment in the commands to be done.
The while loop
while(condition) {
(commands to be done);
}
again, the variable must be declared outside the loop, the increment must be done inside the loop. Very similar to the for loop.
The do whle loop
do {
(commands to be done);
}
while(condition)
The do while loop checks the condition after execution. In the long run, the difference is effectively that it always runs at least once, unlike the other loops.
while(condition)
Posted by Azzarox The Bat. Posted In : Java