Question: public void swap( int p1, int p2){ int ent = p1; p1 = p2; p2 = ent; } Explain why p1 and p2 don't swap
public void swap( int p1, int p2){
int ent = p1;
p1 = p2;
p2 = ent;
}
Explain why p1 and p2 don't swap in with this code AND with what types would swap work
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Solution The reason why p1 and p2 dont swap in this code is because Java is strictly pass by value This means that when you pass a variable to a metho... View full answer
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
