I just wanted to know what is the difference between
a = a+b;
and a += b;
consider,
int a = 10;
long b = 20;
a = a+b; // is not possible
but
a += b; // is possible.
Thank you!
package com.test;
public class ClassCast {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
int a = 1;
long b = 2;
/*Not possible. Compile time error.
a = a+b;
*/
//Possible. Why?
//a += b;
System.out.println(a += b);
}
}