Questions about the definition of the Java language for loop inside and outside variables

Source: Internet
Author: User

Today, when reading a book, see a code, a variable that is not used outside the loop, and then have my problem, in the back:

My question:

Variables are defined within the loop, for example:
while (true) {
String splitstr = null;
}
This "some" of the splitstr is placed in the stack, but their name is the same, then they are the same scope, if so, how do they distinguish? Id? Of course this doesn't seem to make sense, so I have a question that they are useless in the loop, when did the GC clean them up?

This site is a problem I have found, some similar. Feel better.

http://www.iteye.com/problems/74037

Questions about the definition of the Java language for loop inside and outside variables

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.