Link to home
Start Free TrialLog in
Avatar of m-jansen
m-jansen

asked on

method call problems

I have two classes

class one contains
-Array with content
-Method to print the array

class two contains
-methods to manipulate the array in class 1
-calls the one.print

The problem is:
To print the manipulated array made by the methods in class 2, by calling the print method in class one.
I just get the default content when doing that.
Avatar of aozarov
aozarov

Are you sure you are manipulating directly the array that class one holds?
Avatar of m-jansen

ASKER

The array updated with the new content.
I think the problem is that I make a new instance when calling the print method
If you create a new array then make sure you are assiging the new array to class one array variable.
I hope the following is clear to you that it is a mistake and will not change the class one array:

in class two:
method XXX
{
array x = class one.array;
x = new array;
}
ASKER CERTIFIED SOLUTION
Avatar of mightyone
mightyone

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I guess mightyone ment to write:

classA.str[iidx] = s;

instead of
>> A[idx] = s;


of course sorry for that ;-)
and change
set(String s, int idx){
A[idx] = s;
}
to

public void set(String s, int idx){
A[idx] = s;
}
Thanx