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 the function of compareto in java?
What are possible key words, we can use to declare a class?
Which data type is a class in java?
What do you understand by looping in java? Explain the different types of loops.
What is passing parameters in java?
What is string example?
do I need to use synchronized on setvalue(int)? : Java thread
write a class to input 2 points by the user & check the line maked by the points is horizontal,vertical or rectangle?
How do you reverse a list?
why java does not have operator overloading?
What is the difference between compiler and jvm?
Is an integer an object?