• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Wrapper Class

 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 1078
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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.
 
After some pecan pie, you might want to cleanse your palatte with this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic