File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Parameter passing

 
Tutu Upadhyay
Greenhorn
Posts: 1
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi!
Actually i was a bit confused regarding the approach that java follows regarding passing objects as parameters....is it by value or by reference??
I am preperaing for SCJP1.4 and could'nt find a reasonable explanation so far. Would be obliged if u could give a detailed explanation.
Thanx!
regards..
Shambhavi.
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24204
34
Chrome Eclipse IDE Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Welcome to JavaRanch!

Java passes all parameters by value -- but to understand this fully, you have to remember that all objects are referenced via pointers, and it's the pointers, not the objects themselves, that are passed by value when a parameter is an object type.

For a more detailed explanation with examples, please read this and then this.
 
Mahesh Bhatt
Ranch Hand
Posts: 88
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
to clear ur doubt in a shortcut ...remember this ...."in , java, all parameters are passed by value, that is, an actual parameter is eveluated and its value is assigned to the corresponding formal parameter . in a tabular format it would be as below

when its a
Primitive data types(int, byte, etc) then its Primitive data value(value ..note that)


when its a
Class type then its a reference value

when its a

array type then its a reference value
[ September 16, 2004: Message edited by: prashant bhogvan ]
 
Mahesh Bhatt
Ranch Hand
Posts: 88
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
u said u were preparing for certification .... if u r refering the book "khalid mughal and rass....." ...then looking at the diagrams at pages between 86-93 ...willl clear all your doubts in this matter

bye ...
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic