Danielh112 Danielh112 - 2 months ago 11
Java Question

Is it bad to pass class object between methods?

Is it bad to pass instances of objects between methods in a class? Or is there a better way of doing this?

public void game() {
Deck deck = new Deck();

public void changeCard(Deck deck) {


Well... passing class object would be quite difficult in . On the other hand the in-build mechanism of passing value of the reference is very useful and we all do that daily.

Is Java "pass-by-reference" or "pass-by-value"?

Operating with objects is a main principle of Object Oriented Programming and Java is object oriented.

Remember that you don't pass the whole object. You can imagine that as passing the instructions on how to find that object in memory.