0

Need some help in resolving ambiguity wrt to local variables.

I have a java package with 2 class including main. So one main + class1. I have a method in class1 which capture some data in local String objects within the method. I want to use these local string objects in the Main class. Is there a way to do this.

Thank you.

2
  • 4
    Yes, there are. Unfortunately, there are lots of them, so you need to be a lot more specific about the structure of your classes, as well as "capturing" and "using" that String variable. Commented Nov 3, 2014 at 18:47
  • @dasblinkenlight: Hmmm, good point, I may have been too narrow below. Commented Nov 3, 2014 at 18:48

1 Answer 1

1

I want to use these local string objects in the Main class. Is there a way to do this.

The appropriate way to do that is usually to pass them into a method of your Main class as arguments. Or alternately, pass them as arguments into a constructor of your Main class, if it is relevant to the state of a Main instance.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.