wood burning stoves 2.0*
The moose likes Beginning Java and the fly likes Difference between casting and conversion in Java Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Difference between casting and conversion in Java" Watch "Difference between casting and conversion in Java" New topic
Author

Difference between casting and conversion in Java

nidhivel raja
Ranch Hand

Joined: Jun 26, 2008
Posts: 36
Hi all ,
Can anyone please tell me what is the difference between Casting and Conversion in Java?Thank you in advance
Martijn Verburg
author
Bartender

Joined: Jun 24, 2003
Posts: 3274
    
    5

I found this to be a fairly good explanation.


Cheers, Martijn - Blog,
Twitter, PCGen, Ikasan, My The Well-Grounded Java Developer book!,
My start-up.
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19651
    
  18

With casting, you are not modifying the object. The result of the cast is still the exact same object, just with a difference type of reference pointing to it:

With conversion, you are taking the source object and (in most cases) returning a new object based on the old one:


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
bob david
Greenhorn

Joined: Nov 27, 2008
Posts: 4
type casting , explaining with example :

roseindia.net/java/beginners/...

type conversion :

go4expert.com/forums/showthre...


bob david123
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19651
    
  18

Bob, can you please finish that second link? It doesn't point anywhere valid right now, and if I just go to the forum I have to do a search there. I might as well link to our own search.

And moving to beginners.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Difference between casting and conversion in Java
 
Similar Threads
casting reference
Casting & Conversion
what is the diff?
difference between casting and conversion
DownCasting Generally