Re: access array from another classes in java

Re: access array from another classes in java

hey yall i still cant understand why passing an array is so bad, dont you pass single numbers all the time ,then some people call it a bad pratice,the program is designed to do things the fastest possible ,right?
thanks all

Re: access array from another classes in java

Re: access array from another classes in java

Depends. Passing an array can be bad from an OOP perspective, or it could be totally fine. It depends on the context. If I want to search a collection for a name for instance, then it would be silly to retrieve the entire collection for the class that holds it and look myself - it would make more sense for the class that holds it to have a search or find method which I could simply pass parameters to and have it give me a result. That's all part of making your code modular and loosely coupled.