• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

havin problems with Object array

 
Abhi Chat
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • 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....
 
Marlene Miller
Ranch Hand
Posts: 1392
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • 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
  • Quote
  • Report post to moderator
Thanx Marlene..for pointing out that....

abhi
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic