A friendly place for programming greenhorns!
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)
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
posted
Jul 16, 2010 03:16:54
0
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 like...
posted
Jul 16, 2010 03:25:43
0
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
I like...
posted
Jul 16, 2010 04:14:52
0
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
I like...
posted
Jul 16, 2010 04:42:43
0
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
I like...
posted
Jul 16, 2010 05:18:12
0
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
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter