aspose file tools
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes what is the difference int a = (int)(int)b and int a = (int)b Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Reply Bookmark "what is the difference int a = (int)(int)b and int a = (int)b" Watch "what is the difference int a = (int)(int)b and int a = (int)b" New topic
Author

what is the difference int a = (int)(int)b and int a = (int)b

Naresh Shanmugam
Ranch Hand

Joined: Jul 16, 2010
Posts: 82
I have seen typecasting done more than one like

int a = (int)(int)b

Dog obj = (Dog)(Dog)Animalobj

What is difference between

int a =(int)b and
int a = (int)(int) b
Prasad Kharkar
Ranch Hand

Joined: Mar 07, 2010
Posts: 438

I don't think there is important difference in that
because ultimately we are typecasting into some desired type


SCJP 6 [86%] June 30th, 2010
If you find any post useful, click the "plus one" sign on the right
Ankit Garg
Saloon Keeper

Joined: Aug 03, 2008
Posts: 9189
    
    2

The extra type cast is redundant, its allowed but there is no use of it...


SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
Matthew Brown
Bartender

Joined: Apr 06, 2010
Posts: 3793
    
    1

For when you really want to make sure it's a dog.

No, Ankit's right. It has no effect whatsoever. Possibly it had been written by someone that didn't quite understand what was going on.
Ankit Garg
Saloon Keeper

Joined: Aug 03, 2008
Posts: 9189
    
    2

Matthew Brown wrote:For when you really want to make sure it's a dog.

Good one
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: what is the difference int a = (int)(int)b and int a = (int)b
 
Similar Threads
Simple extending enum question...
Comparator Doubt
override and redifinition?
class question
Downcasting And Upcasting