+ 3
[DUPLICATE] Please somebody explain what is the difference between i++ and ++i in java??????
it's breaking my head!!!!!!!
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
+ 7
welcome
+ 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
+ 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);
+ 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 š
+ 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.
+ 3
Ooh) I'm from Kiev)
+ 2
but I expected an answer !!!
+ 2
please make me understand theoretically
+ 2
thanks man it helped . hope you guys keep up the work
+ 2
from where you are??
+ 2
Where are you from? I can explain you...))
0
I am from India and you ??