Access object created in one class into another
问题 I have a primary class as below: public class classB{ public classC getObject(String getstring){ return new classC(getstring); } } The classC has a contructor: public class classC{ String string; public classC(String s){ this.string = s; } public methodC(int i){ <using the `string` variable here> } } Now I've a classA which will be using the object created in classB (which is of course, an instance of classC ). public classA{ int a = 0.5; <Get the object that was created in classB>.methodC(a)