Quantcast
Channel: Difference Between i = i+1 & i++ - Stack Overflow
Viewing all articles
Browse latest Browse all 4

Difference Between i = i+1 & i++

$
0
0

Can anyone solve my confusion here is my code :

byte i = 0;i++;System.out.println(i);

Result: 1

byte i = 0;i = i+1;System.out.println(i);

Generate compile time error: Type mismatch: cannot convert from int to byte

When I convert that to byte like: i = (byte) (i+1); then happily getting result 1

Performing this example i am understand i = i+1 & i++ perform can't same opearation so now i want to know what is exactally difference between them ...!!!


Viewing all articles
Browse latest Browse all 4

Latest Images

Trending Articles





Latest Images