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
  • 744
  • 1
  • 12
  • 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
  • 37,158
  • 8
  • 76
  • 101
0

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

Tim
  • 2,731
  • 9
  • 35
  • 72