• 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
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

havin problems with Object array

 
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I want to have an 2 dimen dynamic object array to get the data from the file and then write it to the Jtable. But I dont want to give the size...

Object [][] o = new 0bject[][];
Like for each iteration

o[i][j]="somedata"

But as it looks it gives me a null pointer exception, could i someway get the things done avodin the exception....
 
Ranch Hand
Posts: 1392
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Abhi,

You can store things in a 1-dim dynamic ArrayList. Then convert the list to a 1-dim array.

I forgot to create a new Object[] at (*). For some reason, I lost the first array. But I am too sleepy to figure out why.
 
Abhi Chat
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanx Marlene...

Actually I also figured similar code through vectors:

 
Marlene Miller
Ranch Hand
Posts: 1392
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Abhi, did you know that Vector is a "legacy" container class. It has been retrofited to be a part of the Java API collections framework. All methods that access the contents of a Vector are synchronized.

My impression is in books authors use ArrayList instead of Vector. I'd use ArrayList unless I really wanted synchronized methods.
 
Abhi Chat
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanx Marlene..for pointing out that....

abhi
 
I don't even know how to spell CIA. But this tiny ad does:
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic