Pass Arrays Constructor Java

Pass Arrays Constructor Java

Pass Arrays Constructor: Sometimes, it is required to pass arrays to methods and constructors to transfer large amount of data between methods.
Following is the example on Pass Arrays Constructor

A teachers string array object is initialized and passed to Publisher constructor.

Now, Publisher constructor receives teachers array object in faculty array object. Now teachers and faculty refer the same location; The concept behind is in "Java objects are passed by reference". Infact, printing of faculty elements prints teachers. elements. The teachers and faculty objects refers or points to the same location. This is how Java achieves pass-by-reference without saying the word "pointers".

Pass Arrays Constructor

For a similar program, passing arrays to methods, refer Java Passing Arrays to Methods where Pass-by-reference affect in Java is shown.

So, now you know how Java supports pass-by-reference or call-by-reference. Java supports almost all but without talking the word pointers. Later in DS, you will come to know how to manage Linked list without pointers.

Pass your comments and suggestions on this tutorial "Pass Arrays Constructor Java".

5 thoughts on “Pass Arrays Constructor Java

  1. test1

    you are in reality a good webmaster. The website loading pace is incredible. It kind of feels that you’re doing any distinctive trick. In addition, The contents are masterwork. you have done a magnificent activity in this topic!

Leave a Reply

Your email address will not be published. Required fields are marked *