Java support call by reference (pass by reference) ?
Answer / 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 |
what is encapsulation in java? Explain
how we can make a write-only class in java?
What is the difference between a loader and a compiler?
What do you mean by thread safe?
What is the exception hierarchy in java?
What is functional interface in java?
Difference between this() and super() in java ?
is java support call by reference and call by value, if supports please explain?
What is instanceof keyword?
what is stringtolennizer with example?
What is the use of System class?
Why const and goto are reserved keyword in java?