int intnum = 10; long longnum = 2; intnum = intnum << longnum; If yes, then can u please explain that what will be the type of result returned by (intnum << longnum)? I think the result should be of type long as one of the operand is long and the other one is int.
Hi, the return type of operator <code> >> </code> or <code> << </font></code> or <code><font color='red'> >>> </code> should be decided by the <code>LHS</code>. The <code>RHS</code> operand just decide how many bit the <code>LHS</code> will be shifted. <code> LHS: left-hand side RHS: right-hand side </code> Hope it helps. Guoqiao
Originally posted by ashok khetan: Does this code compile? int intnum = 10; long longnum = 2; intnum = intnum << longnum;
[This message has been edited by Guoqiao Sun (edited August 16, 2001).]
Guoqiao Sun<br />SCJP2 SCWCD2<br />Creator of <a href="http://www.jiris.com/" target="_blank" rel="nofollow">www.jiris.com</a>, Java resource, mock exam, forum