Accessing variable is other calsses

I also want to access a variable recevieBuffer or a method receivedData(). However they are in another class within the same .java file and the same project. I have a the following classes:

public class Simulation extends UiApplication
 
which is the class that I want to use the variable in
and

class SPPScreen extends MainScreen implements BluetoothSerialPortListener
 
which is the class that contains the variable.

How could I access the variable or the method from the Simulation class?
TheMeeserAsked:
Who is Participating?
 
bgloddeConnect With a Mentor Commented:
You have a couple choices:
> Make the variable static
> Create a public accessor to retrieve the value (eg getVariableValue()) from SPPScreen.



0
 
JConchieCommented:
The meeser......you may want to grade and close some of your previous questions.......or at least respond to the advice given....before asking anymore.
0
 
TheMeeserAuthor Commented:
This helped me out alot, but it took me a little bit to figure out how to do the public accessor part.

Thanks
0
 
TheMeeserAuthor Commented:
Thanks for the tip JConchie :) I have never used anything like this before and wasn't sure how it worked.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.