What is the best way to organize Java code since you can't pass by reference?
- by Adam
I'm learning how to code in Java after after coming from C. In C I always separated everything into individual functions to make the code easier to follow and edit. I was trying to do this in java but now since I realized that you can't use pointers, I am a bit confused as to what the best way to do this is.
So for example I want to have a method that creates four alerts for me. So I pass it an alert builder that can then create the alerts. I can return them in an array, but in my code I already have the alerts individually named, and I would like to keep it that way so I wouldn't need to refer to them as alert[1], alert[2]... etc.
So that means I would have to rename them, which would add additional code which would probably be longer than the code in the actual method!
Am I thinking about this the right way? Is there anything I can do?