Here we put the major cases and below you will get an working example of it.
Rules:
- primitive types are passed by value (example in swapPrimitives function);
- arrays data is passed by reference (example in swapInArray function);
- reassigning the argument inside the method does not affect the variable in the caller function;
- all methods called on the arguments are called on the real object (argument variable could be changed);
Code example: