I tried to pass the arguments ie. an array of int values to the static method insertAt(int [] pindex) and in
java all the method calling is done by call by value.
When you try to execute the pogram you can see,the changes to the pindex[] that is passed on to the that method is reflected in the calling method getTop5(), ie. somthing simmilar to call by reference happens here.
The objects ie all the classes which derive from the base Object class are passed as reference in functions. Just that the pointer handling is hidden in Java. ie say void foo(List l ){ l.add....} The changes in the list l are reflected in the calling function.
From Java Programing Language Student Guide (Sun, page 3-27): The Java Programming language only passes arguments by value. When an object instance is passed as an argument to a method, the value of argument is a reference to the object. The contents of the object can be changed in the called method, but the object reference is never changed.
]
There is nothing as such "Call by Reference", everything in Java is passed by value When you pass a primitive value as an argument to a function you pass a copy of the variable.
However when you pass a reference you pass a copy of the reference thus making to function parameter pointing to the same object, this is again call by value but what gets passed is a copy of reference, so the called function has access to the same object and thus it can manipulate the data members owned by the object.
reference :
[URL=http://faq.javaranch.com/view?CallByReferenceVsCallByValue]http://faq.javaranch.com/view?CallByReferenceVsCallByValue[/URL