Accessing variable is other calsses

Posted on 2006-05-02
Last Modified: 2008-02-26
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

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?
Question by:TheMeeser
    LVL 13

    Accepted Solution

    You have a couple choices:
    > Make the variable static
    > Create a public accessor to retrieve the value (eg getVariableValue()) from SPPScreen.

    LVL 18

    Expert Comment

    The may want to grade and close some of your previous questions.......or at least respond to the advice given....before asking anymore.

    Author Comment

    This helped me out alot, but it took me a little bit to figure out how to do the public accessor part.


    Author Comment

    Thanks for the tip JConchie :) I have never used anything like this before and wasn't sure how it worked.

    Featured Post

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    Join & Write a Comment

    When a user’s mailbox is first created and his Blackberry account enabled how do we provision the device and what happens in the background? Stage 1 – Activation The user of the BlackBerry device types the email address and activation password i…
    Last night I received a weird phone call, from a number I didn’t recognized.  I answered it and no one responded back so I hung up.   Didn’t look at my phone until my husband said “Your phone is doing something weird”.   I had what I’ll consider the…
    To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…
    Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

    755 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    22 Experts available now in Live!

    Get 1:1 Help Now