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

what is meant by jagged array

 
saikrishna cinux
Ranch Hand
Posts: 689
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
can any one tell me what is a jagged array
i nerver gone thru this word in java books


thanks in advance
 
Deepak Bala
Bartender
Posts: 6663
5
Firefox Browser Linux MyEclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A jagged or rugged array is when you have a non uniform array.

A 2 X 2 array will look like this

00
00

A rugged or jagged array might look like this.

00000
00
0000000
0000
00
0

This is achieved when defining the array. You mention that this is an array with 6 elements of depth but you add the width whenever you want with the new operator.

This would not fit under advanced though
 
saikrishna cinux
Ranch Hand
Posts: 689
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanx,but can i create a jagged array in java ?? is it really helpful for a programmer
 
Deepak Bala
Bartender
Posts: 6663
5
Firefox Browser Linux MyEclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes you most certainly can



There are some cases when this can be helpful. Say you have a list of things to add to a data structure like the following...

apple orange
one two four nine seven
bla bla bla

You can put it in a rugged array and then serialize the data in case you want to save it. I have not used rugged/jagged arrays at work ( yet )
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic