Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within OCPJP
Search Coderanch
Advance search
Google search
Register / Login
Post Reply
Bookmark Topic
Watch Topic
New Topic
programming forums
Java
Mobile
Certification
Databases
Caching
Books
Engineering
Micro Controllers
OS
Languages
Paradigms
IDEs
Build Tools
Frameworks
Application Servers
Open Source
This Site
Careers
Other
Pie Elite
all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Campbell Ritchie
Jeanne Boyarsky
Ron McLeod
Paul Clapham
Liutauras Vilda
Sheriffs:
paul wheaton
Rob Spoor
Devaka Cooray
Saloon Keepers:
Stephan van Hulst
Tim Holloway
Carey Brown
Frits Walraven
Tim Moores
Bartenders:
Mikalai Zaikin
Forum:
Programmer Certification (OCPJP)
Casting
Abhi vijay
Ranch Hand
Posts: 509
posted 15 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Source:
K & B Book.
class Redwood extends Tree { public static void main(String[] args) { new Redwood().go(); } void go() { go2(new Tree(), new Redwood()); go2((Redwood)new Tree(), new Redwood());// Line1 } void go2(Tree t1, Redwood r1) {// line2 Redwood r2 = (Redwood)t1; Tree t = (Tree)r1; } } class Tree { }
Here in Line1 (Redwood)new Tree(), so the reference type of t1 in go2 method becomes Rosewood, or it remains the same Tree? Please explain what is happening in line1,2. I am getting confused
Himanshu Gupta
Ranch Hand
Posts: 598
I like...
posted 15 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
web page
This is a recent post on the same question.
My Blog
SCJP 5 SCWCD 5
Don't get me started about those stupid
light bulbs
.
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
A doubt in the type casting
Please help me understanding this
Please explain DownCast Code from K&B
Down Casting to subtype
Java Casting issue
More...