Java support call by reference (pass by reference) ?

Answer Posted / sarju001

yes java support call by reference only using StringBuffer
class.

Here, is an example of call by reference

public class PassByReference
{
public static void passref(StringBuffer s)
{
s = s.insert(8, "j2ee & ");
System.out.println(s);
}
public static void main(String[] args)
{
StringBuffer str = new StringBuffer("Welcome java
program");

System.out.println(str);

passref(str);

System.out.println(str);
}
}


output :-

Welcome java program
Welcome j2ee & java program
Welcome j2ee & java program

Is This Answer Correct ?    9 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Can java run on google chrome?

567


What is the difference between conversation & casting?

566


What is treeset in java?

538


Explain about interthread communication and how it takes place in java?

538


Why is method overloading not possible by changing the return type in java?

583






What is the difference between comparison done by equals method and == operator?

569


What are the advantages of unicode?

541


Can you override static methods?

500


Which package has light weight components in java programming?

673


How do you use find and replace?

507


What is the destroy method?

582


What is Session reduplication and how its done?

1560


What are thread local variables?

544


What is the difference between serializable and externalizable interface?

566


What is udp in java?

529