*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes havin problems with Object array Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "havin problems with Object array" Watch "havin problems with Object array" New topic
Author

havin problems with Object array

Abhi Chat
Ranch Hand

Joined: Oct 10, 2004
Posts: 57
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....


SCJP 1.4<br />Preparing for <br />SCJD and SCWCD
Marlene Miller
Ranch Hand

Joined: Mar 05, 2003
Posts: 1391
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

Joined: Oct 10, 2004
Posts: 57
Thanx Marlene...

Actually I also figured similar code through vectors:

Marlene Miller
Ranch Hand

Joined: Mar 05, 2003
Posts: 1391
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

Joined: Oct 10, 2004
Posts: 57
Thanx Marlene..for pointing out that....

abhi
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: havin problems with Object array
 
Similar Threads
Cast Object to Object[]
Comparison of ArrayList and HashMap
Casting Object to Object Array and vice versa
Casting of Arrays and Object
How can i get all the tables of an active JDBC connections.