This should convert my MessageList ArrayList to an Array which is in a class called Inbox.
My question is that how do i print out all the items in the new array that i just created in a separate test program
Joined: Dec 06, 2001
So are you asking how to print out the contents of an array? If so, you should use a for loop to iterate through the array. Perhaps you should try this first to see what is print out.
However, I doubt you will get useful information since at the moment each element is only an Object. Do you know a more specific type for these elements? If so you should use that type when you call the toArray() method. For instance, if MessageList contains objects of class MyClass, you should do this:
Notice that you can still return Object, but this ensures that the run-time type of each object is actually MyClass, rather than Object as before. Also, the cast that you had isn't necessary since toArray() already returns Object.
The last tid-bit is to make sure your class (MyClass in this case) overrides toString() to return a String with useful information.
I sure hope this isn't too much information. I'm making several assuptions, so if I'm totally off track, perhaps you can post some more information. Specifically, it would be helpful to know what the elements of MessageList are.
p.s. Coding conventions typically state that variable names start with lower case, so MessageList should probably be messageList otherwise it looks like a class name to those of us that are used to the "standard" conventions.
Second maybe for you tonderstand what i am trying to do i have upload my files link here(java_files.zip)
Basically all I want is a method which converts my MessageList ArrayList the Inbox class to an Array and a little test program in Email Organiser that will display the contents of the new Array just created.