aspose file tools*
The moose likes Java in General and the fly likes Wrapper Class Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Wrapper Class" Watch "Wrapper Class" New topic
Author

Wrapper Class

vijay Krishnan
Greenhorn

Joined: Jul 27, 2006
Posts: 14
Hi it's me Again,

class objref
{
void print(Integer I)=============>Wrapper Class object for Integer class.
{
i++;
}
void print(int a[])
{
for(int ij=0;j<a.length;j++)
a[j]++;
}
public static void main(String[] args)
{
Integer i=new Integer(5);=====>object for Integer class;
new objref().print(i);
}
}


* Normally the value of arrayobject which we are passing to the method
is incremented and it is the type of callbyreference.
* But here i had created the object for WrapperClass Integer, but it wont be
like CallByReference model.
* My question is how the CallByReference is working for ArrayClasses and
Whynot to WapperClassess?

* Please Explain anyone with the suitable examples or Explanations.




Thanks & Regards,
Vijay
Ken Blair
Ranch Hand

Joined: Jul 15, 2003
Posts: 1078
Originally posted by vijay Krishnan:

* Normally the value of arrayobject which we are passing to the method
is incremented and it is the type of callbyreference.



No it isn't.

Originally posted by vijay Krishnan:

* But here i had created the object for WrapperClass Integer, but it wont be
like CallByReference model.



Of course not, Java doesn't have pass by reference/call by reference. You mistakenly assumed that's what was happening with the array because you misunderstand what a reference in Java is.

Originally posted by vijay Krishnan:

* My question is how the CallByReference is working for ArrayClasses and
Whynot to WapperClassess?
* Please Explain anyone with the suitable examples or Explanations.



There is only one passing mechanism in Java and it is pass by value. You should read this:

http://www.javaranch.com/campfire/StoryCups.jsp

Hopefully it will help you. I would explain further, but chances are it'd muddy the waters and that page is pretty good at explaining it.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Wrapper Class