Skip to Main Content

New to Java

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Compatible & Incompatible types

967983Mar 26 2013 — edited Mar 27 2013
Why is that I can assign a integer value to a double variable, but cannot assign a double value to an integer variable? Aren't double and integer compatible types? Isn't there a concept of truncation in java? I searched the net but in vain. I couldn't find the exact answer I was looking for. So I am posting in this forum.

PS: I understand it is not possible to assign an integer to a string since they are incompatible types.

Edited by: 964980 on Mar 26, 2013 9:29 PM
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Apr 24 2013
Added on Mar 26 2013
5 comments
292 views