• 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
  • Tim Cooke
  • paul wheaton
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

string Buffer Doubt...

 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


Hi
I think the Output should be "raja". But Raja says that Output is Null. Can anybody explain if it is null.. what is the reason behind that...

Kunal..
[ May 16, 2005: Message edited by: Bhalotia Kunal ]
 
Ranch Hand
Posts: 333
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
class passstringbuf
{
static void stringbufmod(StringBuffer s)
{
s=null;
}
public static void main(String args[])
{
StringBuffer s=new StringBuffer("raja");
stringbufmod(s);
System.out.println(s);
}
}

The o/p will definitely be raja.
Changes made to an object reference inside a method are not reflected outside the method. Of course, changes made to the state of the object are reflected even outside the method.
 
Why am I so drawn to cherry pie? I can't seem to stop. Save me tiny ad!
Clean our rivers and oceans from home
https://www.kickstarter.com/projects/paulwheaton/willow-feeders
reply
    Bookmark Topic Watch Topic
  • New Topic