Monday, January 13, 2014

Passing objects to function : Call by Ref or Call by Value in Java ?

//Note:  Analysis the programs errors,outputs and Understand Passing objects to function : Call by Ref or Call by Value in Java ?


//[1]
//clall by value or call by reference ?
class RefDemo57{

public static void foo(String sb1){

sb1=sb1.concat(" world");
System.out.println("sb1 ="+sb1);   


public static void main(String arg[]){
String sb = new String("Hello");
System.out.println("sb ="+sb);  
System.out.println("sb ="+sb);  
}
}

No comments: