wood burning stoves
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes array passing to method - doubt Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Building Microservices this week in the Design forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "array passing to method - doubt" Watch "array passing to method - doubt" New topic
Author

array passing to method - doubt

raja kanak
Ranch Hand

Joined: Oct 18, 2006
Posts: 135

The above code compiles fine but gives runtime exception ArrayIndexOutOfBoundsException at //1.

My doubt is
don't java pass reference to method argument?


live
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 20057
    
  44

don't java pass reference to method argument?


Java pass a copy of the array reference. This means that if you change the elements of the array, it will change the original array. If you change the array reference itself, it will not affect the original reference.

Henry


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
raja kanak
Ranch Hand

Joined: Oct 18, 2006
Posts: 135

The correct answer is 3. Now I got it. thanks a lot.
 
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com
 
subject: array passing to method - doubt
 
It's not a secret anymore!