Post removed
Printable View
Post removed
You can use an assignment statement to put an object into an array. Given an array: anArray, anObject and an index: theIndexQuote:
trying to import a sinlge object, MM, imto an array of these objects
anArray[theIndex] = anObject; // put anObject into the array at theIndex slot
Can you explain your problem? Do you get errors? If so please post them here.
Does the code execute?
If it does not do what you want it to do, please explain. What do you want it to do that is different from what it does.
Post removed
How does your posted code relate to your question?Quote:
how to pass on the object from its class (movie) to the object array (movieList)
Your posted example does not have an array: movieList or a class movie. What is the name of the object that you want to pass.
movie() appears to be a method. The ending ()s says it is a method.
The only array name I see is MML which is defined in the MovieList class and used in method: importRecord(). Are these two different arrays in two different classes with the same name?
Note: Standard class names begin with uppercase.
You need to use correct terminology when talking about your code.
Thank you for your help: I guess me being new to Java I wouldn't know what I was doing. I thought I created an object of (movie) and I wanted to import that into a position within the movieList (MML) array. Sorry to have bothered you.
Code :{ // --- Create an object --- MyObject obj = new MyObject(); // --- Use the object --- obj.printMyValues(); }
Code :// --- Creating the object --- movie MM = new movie(); // --- Using the object MM.movie_title = movie_title; MM.movie_released = movie_released;
AFAIK
It's important to get the vocabulary right and to use the correct spellings and names when describing a problem. Not many of us are mind readers. There are too many different ways to go wrong that a partial incorrect example makes it very hard to understand what you are trying to do.
Apparently there are too many problems with my code or with what I have said. I do not understand the terms or vocabulary very well: Neither I nor my code can express what I intended.
Movie - Java file
Movie - Class
//details of movie
Menu - Java file
Menu - Method
//create movie object of movie class (MM)
//assign values to movie object (MM)
MovieList - Java file
MovieList - Class
//point to object (MM)
//insert (MM) into array of said objects (MML)
I appreciate you having a look and telling me that I haven't done what I intended to do nor what I have done is correct. It seems I have not only wasted your time but mine as well.
Is this what you are asking about:Quote:
//insert (MM) into array of said objects (MML)
MML[indexOfNextEmptySlot] = MM; // insert/add object MM to the array MML
indexOfNextEmptySlot++; // move index to next slot
Please do not remove your posts like this. You have rendered this thread useless. Next time will be an infraction.