Results 1 to 5 of 5
  1. #1
    kulangotski is offline Senior Member
    Join Date
    Feb 2009
    Posts
    117
    Rep Power
    0

    Default adding more entries at a multidimensional array using a loop

    how do you add items at multidimensional array? the manual type is very simple. I used this

    Java Code:
        private Object[][] data = {
    	    {"Kathy", "Smith",
    	     "Snowboarding", new Integer(5), new Boolean(false)},
    	    {"John", "Doe",
    	     "Rowing", new Integer(3), new Boolean(true)},
    	    {"Sue", "Black",
    	     "Knitting", new Integer(2), new Boolean(false)},
    	    {"Jane", "White",
    	     "Speed reading", new Integer(20), new Boolean(true)},
    	    {"Joe", "Brown",
    	     "Pool", new Integer(10), new Boolean(false)}
            };
    but my problem is that the entries are not static, they are coming from a jdbc result set.
    I am trying to see if it is possible for me to loop those things on my result set so I can place them on a multidimenstional array.

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    25

    Default

    It looks as if you're trying to create data to be displayed in a Swing JTable. If so, then don't use arrays, but use Vector of Vectors instead and a DefaultTableModel object. Or any other collection such as ArrayList, but then you'll need to use an AbstractTableModel, not the DefaultTableModel.

  3. #3
    kulangotski is offline Senior Member
    Join Date
    Feb 2009
    Posts
    117
    Rep Power
    0

    Default

    ok then, i think that is all that I need to know. thank you very much :D

  4. #4
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    25

  5. #5
    kulangotski is offline Senior Member
    Join Date
    Feb 2009
    Posts
    117
    Rep Power
    0

    Default

    ei, tried to use the arraylist method and it works like magic.. thanks

    regards

    simon

Similar Threads

  1. initialize multidimensional array
    By Aidoru in forum New To Java
    Replies: 2
    Last Post: 12-04-2010, 01:00 PM
  2. Adding up all values generated from a for-loop
    By BariMutation in forum New To Java
    Replies: 4
    Last Post: 10-10-2010, 05:31 PM
  3. Retrieve Multidimensional Array ??
    By oneofthelions in forum New To Java
    Replies: 3
    Last Post: 12-12-2009, 07:24 AM
  4. Navigate through a multidimensional array
    By VinTiger in forum New To Java
    Replies: 4
    Last Post: 05-05-2009, 07:16 PM
  5. [SOLVED] Multidimensional array
    By Torgero in forum New To Java
    Replies: 20
    Last Post: 03-22-2009, 11:36 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •