Why Did Java Community Decided To Pass Primitives By Value And Objects By Reference?
My guess is that primatives are usually small and that user-defined objects can get very big. If you had to pass a huge object by value every time, you would eat up a terrible amount of memory for no good reason. And you would probably want to pass the large object by reference anyway for simplicity's sake. I guess passing primatives by reference could save work in some cases, but it seems prone to cause confusion as well. I'm only guessing, though. Good luck!
Just to confuse you. Ha no just kidding, its to increase the compatibilty so its the ideal cross-platform language. Just be careful while declaring objects using other objects and it doesn't pose much of a problem.
My guess is that primatives are usually small and that user-defined objects can get very big. If you had to pass a huge object by value every time, you would eat up a terrible amount of memory for no good reason. And you
would probably want to pass the large object by reference anyway for simplicity's sake. I guess passing primatives by reference could save work in some cases, but it seems prone to cause confusion as well. I'm only
guessing, though. Good luck!
if u have a variable that is a primitive and want to pass it to a function which will change it , you have to pass it by reference.If you ever want to send something to a function and be altered , u should pass by
reference.It also helps performance mentioned above