• Post Reply Bookmark Topic Watch Topic
  • New Topic

"2D array"  RSS feed

 
Cougar Vis
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I wanted to create a 2d array and store info into it, but don't know how to do it does anyone have some links or code to show me how to do a 2D array?
 
Layne Lund
Ranch Hand
Posts: 3061
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can create a 2D array like this:

int[][] array2D = new int[5000][200];

Subscripting is pretty straight-forward:

array2D[i][j] = i + j;

This assumes that i and j have valid index values.

HTH

Layne
 
Cougar Vis
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
can i stick a varible inside the [] instead of a value???
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24217
38
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by GK Leo:
can i stick a varible inside the [] instead of a value???


Yes.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!