This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Journal Article - SCJP Tip Line - Implicit Conversions, Explicitly Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Journal Article - SCJP Tip Line - Implicit Conversions, Explicitly" Watch "Journal Article - SCJP Tip Line - Implicit Conversions, Explicitly" New topic
Author

Journal Article - SCJP Tip Line - Implicit Conversions, Explicitly

Dirk Schreckmann
Sheriff

Joined: Dec 10, 2001
Posts: 7023
The just-released October 2004 edition of The JavaRanch Journal includes an article by Corey McGlone, "The SCJP Tip Line - Implicit Conversions, Explicitly".

Please use this thread to comment on and discuss the article.


[How To Ask Good Questions] [JavaRanch FAQ Wiki] [JavaRanch Radio]
pradyot sikdar
Greenhorn

Joined: Jul 11, 2005
Posts: 1
There is an exception to "narrowing conversion".
In case of "narrowing conversion" we always do explicit casting.Like if we are assining an int value to a byte value.
int i = 10;
byte b = (byte)i;
But we can also do narrowing conversion with out any explicit casting.
For this we have to remember two things.
1) The value which we are going to assign must be final.
2) The value which we are going to assign should accommodate well into the data type length of the variable where we are going to assign.
For example,
final int i = 10;
byte b = i;
This will not give any compilation error.
final int i = 129;
byte b = i;
But this will give any compilation error.Here we need explicit casting.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Journal Article - SCJP Tip Line - Implicit Conversions, Explicitly
 
Similar Threads
Journal Article - The SCJP Tip Line - Strings, Literally
Journal Article - The SCJP Tip Line - hashCodes Uncovered
SCJP Tip Line: More about Conversions
why no error with byte b=3+5
Journal Article - The SCJP Tip Line - Bit Shifting