aspose 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
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
 
jQuery in Action, 2nd edition
 
subject: Query about the enhanced for loop