aspose file tools*
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 EJB 3 in Action this week in the EJB and other Java EE Technologies 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: 18108
    
  39

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 agree. Here's the link: http://aspose.com/file-tools
 
subject: array passing to method - doubt
 
Similar Threads
doubt
Doubt
Inheritance Doubt?
doubt
Inheritance doubt