File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Query about the enhanced for loop Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Query about the enhanced for loop" Watch "Query about the enhanced for loop" New topic
Author

Query about the enhanced for loop

Harish Kamath
Greenhorn

Joined: Aug 24, 2012
Posts: 2
A quick question about the below example that I came across on CertPal



The output of the above is

5

How is it possible to assign a two dimensional String array to a single dimensional Object array?

Thanks in advance.
Enkita mody
Ranch Hand

Joined: Aug 06, 2012
Posts: 333

Each array is an Object type okay ? GOOD BYE


OCA7
Harish Kamath
Greenhorn

Joined: Aug 24, 2012
Posts: 2

ankita modi. wrote:Each array is an Object type okay ? GOOD BYE


Yes - my question was more specific to the dimension of the reference type. The reference type definition has one dimension where as the initialization has two dimensional String array.

Object[] obj = new String[5][5];

Note that it is Object [] I would have expected it to be something like Object [][].

Enkita mody
Ranch Hand

Joined: Aug 06, 2012
Posts: 333

Array or array of arrays it doesn't matter, it is type of Object.Okay?

-hth
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Query about the enhanced for loop