I want to know if have two arrays testSet and testSet2 of class test1 in method problem() testSet is initialized to 1 and testSet2 is initialized to 0 and after equalizing the testSet2 with testSet the testSet2 lenght become same as of testSet which is fine but in method problem1() testSet is initialized to 1 and testSet2 is initialized to 0 and after equalizing in method equalize() the testSet2 with testSet the testSet2 lenght become is still 0. why?
public class test1
{
// C
public test1(int _data)
{
data = _data;
}
// Field
public int data;
}
// reference equalize method
public void equalize(test1[] a,test1[] b)
{
a = b;
}
public test1[] testSet,testSet2; // arrays
// called from main method access
public void Problem()
{
// initializing array
testSet = new test1[1];
testSet2 = new test1[0];
testSet [0] = new test1 (11);
testSet2 = testSet;
// testSet2.length = 1 which is fine
}
// called from main method access
public void Problem1()
{
testSet = new test1[1];
testSet2 = new test1[0];
testSet [0] = new test1 (11);
equalize (testSet2,testSet);
// want to know why this is happening ?
// testSet2.length = 0
// in problem() length = 1 but here is 0 why?
}