aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Conversion..... Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Conversion....." Watch "Conversion....." New topic
Author

Conversion.....

Vasiq Molvizadah
Ranch Hand

Joined: Dec 24, 2009
Posts: 66
This question is from the SCJP6 book...



I've 2 question

1. Is this possible "(int[]) a[1]" ...or is it just to confuse it.

2. At line 3, why it didn't show that o1 is an array of array not array, why it was shown at the runtime..


Human Knowledge Belongs to the World.
- Vasiq Mz
Jim Hoglund
Ranch Hand

Joined: Jan 09, 2008
Posts: 525
If 'a' is a two dimension array (int[][]) then each element is a one dimension array (int[]).
So casting this way is not necessary; yes, just to confuse you. On your second question,
the compiler only knows 'o1' as an Object so it thinks the cast is okay. But at run time the
JVM knows that 'o1' is a 2-d array.

Jim ... ...

BEE MBA PMP SCJP-6
Vasiq Molvizadah
Ranch Hand

Joined: Dec 24, 2009
Posts: 66
Jim Hoglund wrote:If 'a' is a two dimension array (int[][]) then each element is a one dimension array (int[]).
So casting this way is not necessary; yes, just to confuse you. On your second question,
the compiler only knows 'o1' as an Object so it thinks the cast is okay. But at run time the
JVM knows that 'o1' is a 2-d array.

Jim ... ...


Ok buddy thanks a lot for the solution, so even you are preparing for the SCJP exam (on your signature), same here buddy
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19781
    
  20

I think this thread fits better in our SCJP forum. Moving there.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Conversion.....