Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Create an array

 
Milind Deodhar
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
I want to create an array like this
--Index, integer, and char
1. 12 A
2. 9 B

How can that be done in Java,
Thanks a lot.
 
Gregg Bolinger
GenRocket Founder
Ranch Hand
Posts: 15302
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Array[][] - Multidimensional Array. You will probably want to use an Object[][] type so you can store the different data types appropriatly. The index will be kept via the Array itself.
 
Milind Deodhar
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the reply,
Suppose I have a 2 dimension array like this
int, int
How do I write the for loop to access this array.
Thanks
Milind.
 
Dirk Schreckmann
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Milind D,
Welcome to JavaRanch!
We ain't got many rules 'round these parts, but we do got one. Please change your display name to comply with The JavaRanch Naming Policy.
Thanks Pardner! Hope to see you 'round the Ranch!
 
William Barnes
Ranch Hand
Posts: 986
Eclipse IDE Firefox Browser Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Suppose I have a 2 dimension array like this
How do I write the for loop to access this array.

 
Dirk Schreckmann
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Where
MAX_I = arrayVar.length;
and
MAX_J = array[i].length;
 
William Barnes
Ranch Hand
Posts: 986
Eclipse IDE Firefox Browser Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
int MAX_I = ...
int MAX_J = ...
int[][] arrayVar = new int[ MAX_I ][ MAX_J ] ;
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic