• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Dynamic 2d array size?

 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i have a 2d array that i am filling with data from an sql database. I would like the table to only be as big as the size of the database. 24 rows fit in the JScrollPane before the auto scroll starts so 24 as a default could be ok...how do i change it so i dont get an out of bounds exception once i go past 24?




i tried to make a loop that went through the results first and stored an index value...but then the table displays blank.



then use length instead of 24





But just displays a blank table...it is the correct size table though
 
Derek Rose
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
sorry, dumb mistake i fixed it
 
Marshal
Posts: 79178
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Derek Rose wrote:i have a 2d array . . .

No, you haven’t. You have an array of arrays, which is different. And better.

Never use == true or == false.
What a strange loop! Was that what you had to fix?
 
Derek Rose
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I needed to execute a different query for each loop. And I started learning Java last month and your the third person to tell me my logic is weird. That's just the way the solution comes to me haha
 
What's gotten into you? Could it be this tiny ad?
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic