0

I'm asking if I create a Custom Class object with say 100 integer values in it.

If I were to pass that variable into a method that contains and object of the same type I am only passing a refernce to the source object, I'm not making a duplicate of those 100's of variables, right?

  class BigClass {
    int A;
    int B;
    ...
  }

   BigClass ThisClass = new BigClass();


   private void DoSomething(BigClass b) {
          BigClass ThatClass = b; 
   }


   **************

   DoSomething(ThisClass);
GideonKain
  • 754
  • 1
  • 11
  • 27
  • [This](http://stackoverflow.com/questions/40480/is-java-pass-by-reference) may interest you. – Pshemo Jul 26 '12 at 20:05

2 Answers2

2

Correct, just the reference to the instance of your class will get passed/copied. The actual guts of your class will not be copied.

See Jon Skeet's article about parameter passing in Java, it does a good job of explaining things.

wsanville
  • 36,693
  • 7
  • 74
  • 101
0

That is correct. When you pass objects to another class, you are simply passing a reference to it.

Tim
  • 2,551
  • 6
  • 33
  • 68