Home >Java >Javagetting Started >What is the difference between for statement and while statement in java
The difference between the for statement and the while statement is as follows:
Main manifestations:
(Video tutorial recommendation: java video)
From a memory perspective, after the for loop ends, the variable in the loop is released from the memory in time, and the variable can no longer be accessed outside the for loop; and after the while loop ends, it can still be accessed outside the while loop. This variable will be released when the GC is idle.
Recommended tutorial: java entry program
The above is the detailed content of What is the difference between for statement and while statement in java. For more information, please follow other related articles on the PHP Chinese website!