Switch to full style
Java2 codes,problems ,discussions and solutions are here
Post a reply

Here is how to display any 2d array

Sat Jun 09, 2007 11:54 am

Now .
IF you have multi-D (2D) Array of Strings you can do the following with out writing the size every time you display 2d array , Just make a Function and pass the 2d array to it as a parameter.

java code
for(int i=0;i<arr.length ;i++) 
{ System.out.print("| ");
for(int j=0;j<arr[0].length;j++)
{ System.out.print(arr[i][j]+" "); }
System.out.println("| "); }


another improvement :mrgreen:
java code
for(String[] i:arr)
for(String j:i)
System.out.print(j+" ");




Post a reply
  Related Posts  to : Here is how to display any 2d array
 Array difference for associate array     -  
 display list     -  
 SEVEN SEGMENT DISPLAY     -  
 Can I display same vertically on right side?     -  
 Display images on jsp from servlet     -  
 Display a different image for each day of the week     -  
 How can i display these items in Listview in C#?     -  
 display code block using html     -  
 display the content of text file     -  
 read php file in asp and display it as html     -  

Topic Tags

Java Arrays