I have a main class as shown below:
public class classB{
public classC getObject(String getstring){
return new classC(getstring);
}
}
classC has a constructor:
public class classC{
String string;
public classC(String s){
this.string = s;
}
public methodC(int i){
<using the `string` variable here>
}
}
Now I have classAone that will use the object created in classB(which, of course, is an instance classC).
public classA{
int a = 0.5;
<Get the object that was created in classB>.methodC(a);
}
This is necessary because the variable is created during some user actions and stored in classB, and this will be used later in the methods classC. Creating a new object will make my variable classBequal to zero, which is not intended.
How can i achieve this?
source
share