Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Query about the enhanced for loop

 
Harish Kamath
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 333
Firefox Browser Java Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Each array is an Object type okay ? GOOD BYE
 
Harish Kamath
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
Posts: 333
Firefox Browser Java Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Array or array of arrays it doesn't matter, it is type of Object.Okay?

-hth
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic