• Post Reply Bookmark Topic Watch Topic
  • New Topic

Array syntax  RSS feed

 
Karen Boxby
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This was an answer on one of the Exam Lab tests and I'm struggling to make sense of it:Is the "[]{{1}}[0]" initializing an array to an element of "1" and then extracting that element for use in initializing the first "[]"?
 
Joe Areeda
Ranch Hand
Posts: 334
2
Java Netbeans IDE Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think you got it. Pretty weird syntax, I doubt you'll every see it in real life.

new int[][]{ {1} } creates a 2 dimensional array with one row and 1 column and [0][0] = 1; Then [0] specifies the first row which is an array of one element.

Joe
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!