This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
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 Android Security Essentials Live Lessons this week in the Android 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: 18532
    
  40

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