If I have the following code, what will the integer “i” be equal to after it executes? Does a loop increment after a break statement?
int i = 0;
for(int foo = 0; foo < 10; foo++,i++){
break;
}
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Why don’t you put a println and see…
I’m going to say it ends up with what you started (i.e., zero — the increment happens after the code in inside the for executes — since you break out of it, it never gets to increment).