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.