• 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

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
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic