We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hello All, I am currently having a problem in creating an arraylist of objects, each with store a group of various data to be used to draw different shapes. I have a generating class object which generates the data with point location for lines, curves, and what have you in a 2d array, alone with colour and start and stop points etc. I the generator then creates a new class object of a shape class in a arraylist of shape object using that data. But once it completes the first shape and starts on the second one the 2d array data changes within the first shape object as well as the new array is being decided. All the other data types don't change, but for some reason if i use a regular 2d array of ints in the arraylist of shape objects it will be that same for all of them. I thought that once the new object within the arraylist was declared, and those variables are assigned within the object instance of that class that they wouldn't change unless they we directly changes via a function or command etc. Ie it would be a 'snapshot' coping all the various variables and storing them within the object within the arraylist for use later.
I've tried a few wireframe tests to see if it was an error in my code or something to do with the nature of processing and so far if I make an arraylist of objects, and these objects use a 2d array in the declaration of the object, the data within the object will change it the original date referenced to make that object is changed after it is create. But other data types seem ok.
I can try and post some code if someone thinks they can help or if that might be able to explain it in abstract.
Answers
post some code
This sounds like a pass by value / reference problem -- that is how Java works, nothing specific to Processing. ( https://stackoverflow.com/questions/40480/is-java-pass-by-reference-or-pass-by-value )
However, it will be easier to spot the problem if you post some code.