+ 3

[DUPLICATE] Please somebody explain what is the difference between i++ and ++i in java??????

it's breaking my head!!!!!!!

15th Mar 2018, 11:07 AM
Devansh Gupta
Devansh Gupta - avatar
13 Answers
+ 8
👉ultimate answer ::: int a=1,b; case 1) a=a++; //final value of a will be 1 case 2) b=a++; //final value of b will be 1,a=2 case 3) a=++a; //final value of a will be 2 case 4)b=++a; //final value of b will be 2 , a=2
15th Mar 2018, 11:30 AM
Gaurav Agrawal
Gaurav Agrawal - avatar
+ 7
welcome
15th Mar 2018, 11:35 AM
Gaurav Agrawal
Gaurav Agrawal - avatar
+ 6
code playground is the best way to understand something , btw this will help u understand it perfectly https://www.sololearn.com/Discuss/1140298/?ref=app
15th Mar 2018, 11:27 AM
Gaurav Agrawal
Gaurav Agrawal - avatar
+ 6
this may perhaps help you : int i; String a,b ; i = 1; System.out.println(i); a = String.valueOf(i++); System.out.println(""+ i +" - " + a); b = String.valueOf(++i); System.out.println(""+ i +" - " + b);
15th Mar 2018, 11:29 AM
Geo
Geo - avatar
+ 6
i just answerd this somewere else😂 i++ uses the value of i and then increments which basicly means that the old value of "i" will be used first and then the new value will be used next ++i increments the value of "i" and then uses it. ++i looks like i+=1. you may see i++ & ++i gets used in alot of programs using "i" as the variable but you can use anything ++gaurav or stark++ hope that helps 👍
15th Mar 2018, 12:46 PM
D_Stark
D_Stark - avatar
+ 5
Prefix means : First change , then use. Postfix means : First use , then change. Suppose : int a=1,b; 1st case : b = a++; // value of a is 2 and b is 1. 2nd case : b = ++a; // value of a is 2 and b is also 2.
15th Mar 2018, 12:23 PM
cHiRaG GhOsH
cHiRaG GhOsH - avatar
+ 3
Ooh) I'm from Kiev)
15th Mar 2018, 2:45 PM
Anastasia Kolesnikova
Anastasia Kolesnikova - avatar
+ 2
but I expected an answer !!!
15th Mar 2018, 11:28 AM
Devansh Gupta
Devansh Gupta - avatar
+ 2
please make me understand theoretically
15th Mar 2018, 11:30 AM
Devansh Gupta
Devansh Gupta - avatar
+ 2
thanks man it helped . hope you guys keep up the work
15th Mar 2018, 11:32 AM
Devansh Gupta
Devansh Gupta - avatar
+ 2
from where you are??
15th Mar 2018, 11:36 AM
Devansh Gupta
Devansh Gupta - avatar
+ 2
Where are you from? I can explain you...))
15th Mar 2018, 1:31 PM
Anastasia Kolesnikova
Anastasia Kolesnikova - avatar
0
I am from India and you ??
15th Mar 2018, 2:32 PM
Devansh Gupta
Devansh Gupta - avatar