This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes doubt in java conversion Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Beginning Java
Bookmark "doubt in java conversion" Watch "doubt in java conversion" New topic
Author

doubt in java conversion

J radolf
Ranch Hand

Joined: Jan 08, 2009
Posts: 121

in the doubt line why type conversion does not take place and no error.???
Brian Cole
Author
Ranch Hand

Joined: Sep 20, 2005
Posts: 875
    
    1
january radolf wrote:
in the doubt line why type conversion does not take place and no error.???


What is the nature of your doubt? Perhaps you are worried that b1 += 3 should be the same as b1 = b1 + 3?

It is true that b1 = b1 + 3 has a type error and needs to be written b1 = (byte)(b1 + 3).

But it is also true b1 += 3 does in fact mean b1 = (byte)(b1 + 3) according to §15.26.2 of the JLS.

(The 2nd edition of the JLS mentions that the cast is either a narrowing primitive conversion or an identity conversion, but the 3rd doesn't presumably due to boxing/unboxing issues.)

bitguru blog
J radolf
Ranch Hand

Joined: Jan 08, 2009
Posts: 121
Thank you for your clarification.
 
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com
 
subject: doubt in java conversion
 
It's not a secret anymore!