I am still a beginner to java and I have a question on an efficient way to pass in parameters. When passing in objects in a method is it more efficient to pass in portions of an object or does it not matter at all? for example, lets say I have a Person object which has several attributes (name, height, gender, location, hairColor etc.) and I have a method which needs to work on two of these attributes. When I pass the info into the method, does it save me memory, process time etc to only pass in the needed info (like name and location) or is it the same as just passing in the whole person object?
is:
public void getNamePlace(String name, String location){
\\\\work here
}
any different efficiency-wise than:
public void getNamePlace(Person person){
\\\\work here and get the name location in the method
}
Thanks a lot for the help. I'm sorry if it is a dumb question but I'm trying to figure out the best mentality to approach this. Thank you.
p.s. I am thinking more on the method call itself. How does it work. In isolation, is:
public void getNamePlace(String name, String Location) --> More bits passed around and memory used than --> public void getNamePlace(Person person)