This is what you would call a "cast & pray" cast, also known as a explicit
cast ;-)

These types of cast require explicit knowledge in the type of data that is
being returned and you use it the knowledge that either a change in the type
of data returned will never change, or that you are happy for the code to
throw a Cast Exception if it does, and hope it gets picked up in testing.



------------------------------------------------------------------------- 
Keith Sterling         
Jacobs Rimell
VP of Engineering
Jacobs Rimell Ltd
24 Chiswell St
London EC1Y 4TY             
Tel : +44 207 786 4000
Mob : +44 7771 597 630 
Fax : +44 207 786 4004 
http://www.jacobsrimell.com 
------------------------------------------------------------------------- 
IMPORTANT NOTICE: 
This email is confidential, may be legally privileged, and is for the
intended recipient only.  If you are not the intended recipient, please
inform the sender and delete the email immediately.
WARNING: 
It is impossible to guarantee the content of this message when it is
delivered across the internet, therefore the  sender accepts no liability
for any claims arising from the information contained.
 
 

> -----Original Message-----
> From: Fewtrell, Tom [mailto:[EMAIL PROTECTED]]
> Sent: 07 May 2002 11:41
> To: JDJList
> Subject: [jdjlist] RE: [jdjlist] RE: [jdjlist] casting
> 
> Something like ...
> 
>     java.util.Iterator it = results.iterator();
> 
>     String resultsString = (String)it.next();
> 
> We are making explicit that the Object should be cast to String
> 
> -----Original Message-----
> From: Emmanuel Eze [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, May 07, 2002 10:43 AM
> To: JDJList
> Subject: [jdjlist] RE: [jdjlist] RE: [jdjlist] casting
> 
> 
> can u give an example of explicit cast?
> 
> -----Original Message-----
> From: RAMESH VISHNUVARDHAN [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, May 07, 2002 12:18 PM
> To: JDJList
> Subject: [jdjlist] RE: [jdjlist] casting
> 
> 
> 
> When you assign a variable of parent class type to an object of subclass,
> the implicit casting occurs.
> Example:
> java.util.Date parentDate = null;
> parentDate = new
> java.sql.Date(Calendar.getInstance().getTime().getTime());
> The above code is valid. Here we no need to do explicit casting
> .
> Regards,
> Vishnu
> 
> 
> -----Original Message-----
> From: Emmanuel Eze
> To: JDJList
> Sent: 5/7/02 11:08 AM
> Subject: [jdjlist] casting
> This cast thing is beginning to get me confused. if I cannot cast a
> java.util.Date to a java.sql.Date since the util.Date is the ancestor
> class,
> can I cast a java.sql.Date to java.util.Date.  I really wish to
> understand
> the nitty gritty of casting.
> 
> 
> 
> 
> 
> To change your membership options, refer to:
> http://www.sys-con.com/java/list.cfm
> 
> 
> To change your membership options, refer to:
> http://www.sys-con.com/java/list.cfm
> 
> This e-mail and any attachment is for authorised use by the intended
> recipient(s) only.  It may contain proprietary material, confidential
> information and/or be subject to legal privilege.  It should not be
> copied, disclosed to, retained or used by, any other party.  If you are
> not an intended recipient then please promptly delete this e-mail and any
> attachment and all copies and inform the sender.  Thank you.
> 
> To change your membership options, refer to:
> http://www.sys-con.com/java/list.cfm

To change your membership options, refer to:
http://www.sys-con.com/java/list.cfm

Reply via email to