Go4Expert

Go4Expert (http://www.go4expert.com/)
-   Java (http://www.go4expert.com/forums/java/)
-   -   displaying 2-dimensional arrays in JSPs (http://www.go4expert.com/forums/displaying-2-dimensional-arrays-jsps-t4480/)

champion 30May2007 11:44

displaying 2-dimensional arrays in JSPs
 
NB: All code given is Java code

I have declared my variable as follows:

String [][] agent = new String[][];

I have populated the array successfully.

I now want to print the contents of my array side by side as agent[0][0] to give me an output like: Eddy 0.8 where Eddy is in the row and 0.8 is in the column.

Thank you guys!

msi_333 30May2007 21:57

Re: displaying 2-dimensional arrays in JSPs
 
Now .
IF you have multi-D Array of Strings you can do the following . :D

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("| ");
        }


champion 31May2007 11:20

Re: displaying 2-dimensional arrays in JSPs
 
i want to display the results in a jsp.

any suggestions?


All times are GMT +5.5. The time now is 14:27.