in java what is the difference between ++i and i++ and what is the effect of both in loop ?
Question
Share
Sign Up to our social questions and Answers to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers 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.
They both increment the number with value 1
but but ++i increment the number before the current expression is evaluted, whereas i++ increment the number after the expression is evaluated
for example
int i=5;
int z=i++; //z equals 5 here
int x=++i; //x equals 6 here