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 about anonymous inner classes in java?
What is jvm? Why is java called the platform independent programming language?
What is lexicographically smallest string?
When does a class need a virtual destructor?
How do you print array in java?
What is break and continue statement?
How do you escape in java?
Java support call by reference (pass by reference) ?
What is the difference between actual and formal parameters?
State the main difference between c++ and java?
Does a class inherit the constructor of its super class?if it does, how can you hide that constructor? if it doesnot how can you call it from the sub class?
How does a cookie work in Servlets?