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
Paul Clapham
Ron McLeod
Jeanne Boyarsky
Tim Cooke
Sheriffs:
Liutauras Vilda
paul wheaton
Henry Wong
Saloon Keepers:
Tim Moores
Tim Holloway
Stephan van Hulst
Carey Brown
Frits Walraven
Bartenders:
Piet Souris
Himai Minh
Forum:
Programmer Certification (OCPJP)
Casting
Abhi vijay
Ranch Hand
Posts: 509
posted 13 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 13 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
Clowns were never meant to be THAT big! We must destroy it with this tiny ad:
free, earth-friendly heat - a kickstarter for putting coin in your pocket while saving the earth
https://coderanch.com/t/751654/free-earth-friendly-heat-kickstarter
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...