displaying 2-dimensional arrays in JSPs

Discussion in 'Java' started by champion, May 30, 2007.

  1. champion

    champion New Member

    Joined:
    May 29, 2007
    Messages:
    9
    Likes Received:
    1
    Trophy Points:
    0
    Occupation:
    Analyst Programer
    Location:
    Harare, Zimbabwe
    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!
     
  2. msi_333

    msi_333 New Member

    Joined:
    May 29, 2007
    Messages:
    22
    Likes Received:
    0
    Trophy Points:
    0
    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("| ");
            }
     
  3. champion

    champion New Member

    Joined:
    May 29, 2007
    Messages:
    9
    Likes Received:
    1
    Trophy Points:
    0
    Occupation:
    Analyst Programer
    Location:
    Harare, Zimbabwe
    i want to display the results in a jsp.

    any suggestions?
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice