Welcome to the ranch, Rafael. In the changeB(...) method you are indeed swopping the values assigned to the variables 'a' and 'b', but these local variables, being the method's parameters, only have scope within that method. The same-name 'a' and 'b' local variables in the main method are not changed. I think this overlaps with with Adrian's answer (which came up after I saw the Q and before I posted), but I should remind myself of the the whole pass-by-referencs vs. pass-by-value thing in case I explain it incorrectly . (I don't want to suggest a work-around as I don't know what the practical goal would be.)
You have written some confusing code, with all the code squashed up. Make your indents deeper and put empty lines between successive methods. Spaces after every comma (line 16). Don't declare two variables on the same line. You will then end up with something like this:-Let's simplify that code, because there are easier ways to print those values:-Let's give the methods names that reflect what they are doing, and the class a better name, too.Now you have some code you can actually read. Also, the array will print as [1, 2, 3, 4, 5]; the  will make it clear which of the output is array and which the two Strings.
Corrected spelling error (off→of)
posted 1 week ago
Sorry; I pushed the wrong button and posted an incomplete post.
Both people who posted last night were correct. If you look here, you will find it says this:-
. . . in Java primitives are passed by value and objects are passed by reference.
...followed immediately by
It is not correct.(My emphasis)
If you read the whole of that link, you will see it tells you quite clearly that Java® only supports pass‑by‑value, even quoting from the Java® Language Specification (=JLS) where it says that. This is probably the crucial part of the quote:-
newly created parameter variables
As EB told you, the a and b in the swap method are now new variables, completely separate from the originals, and changing the identity of the variables in the swap method does not make any changes to the originals. That means the two Strings in lines 19‑20 are exactly the same as they were before.
In the second method, you are passing an array, whose original state is [1, 2, 3, 4, 5]. It is possible to manipulate that array because it is a mutable reference type and change its state to [2, 4, 6, 8, 10]. That does not mean you have changed the identity of the array. Its memory location will be exactly the same, but it is possible to change its state, i.e. the values of its elements. That can be done for any array of any type (with one special exception) or for any object with methods available to change its state.If you display that account, it is the same account as before. All its details will be unchanged, except that I now have the amount of money I deserve
You showed up just in time for the waffles! And this tiny ad: