Page 3 of 3 FirstFirst 123
Results 41 to 46 of 46
Like Tree1Likes

Thread: How to access a variable in one class from another?

  1. #41
    Snake006 is offline Member
    Join Date
    Jun 2013
    Posts
    95
    Rep Power
    0

    Default Re: How to access a variable in one class from another?

    ok I read that just now

  2. #42
    Snake006 is offline Member
    Join Date
    Jun 2013
    Posts
    95
    Rep Power
    0

    Default Re: How to access a variable in one class from another?

    So anyone know what I should do next?

  3. #43
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,458
    Blog Entries
    7
    Rep Power
    20

    Default Re: How to access a variable in one class from another?

    Quote Originally Posted by Snake006 View Post
    So anyone know what I should do next?
    Implement that singleton I mentioned?

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  4. #44
    Snake006 is offline Member
    Join Date
    Jun 2013
    Posts
    95
    Rep Power
    0

    Default Re: How to access a variable in one class from another?

    I sort of did that but I am not sure how to link my local town class bank to that singleton. I used bankStuff.getBank() in my constructor

  5. #45
    Snake006 is offline Member
    Join Date
    Jun 2013
    Posts
    95
    Rep Power
    0

    Default Re: How to access a variable in one class from another?

    plus shouldn't that singleton be of type int? It is of type bankStuff instead.

  6. #46
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,458
    Blog Entries
    7
    Rep Power
    20

    Default Re: How to access a variable in one class from another?

    Quote Originally Posted by Snake006 View Post
    plus shouldn't that singleton be of type int? It is of type bankStuff instead.
    Just suppose (a mad idea, I know) that the singleton carries an int as one of its member variables and it has methods getTheInt() and setTheInt(int theInt) ...

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

Page 3 of 3 FirstFirst 123

Similar Threads

  1. How to Access and Set variable in parent class
    By java_newbie88 in forum New To Java
    Replies: 6
    Last Post: 01-20-2011, 02:48 AM
  2. how to access JSP variable in javascript
    By sauravsinha in forum JavaServer Pages (JSP) and JSTL
    Replies: 1
    Last Post: 03-31-2010, 04:41 PM
  3. variable access from another file
    By riadmazloum in forum AWT / Swing
    Replies: 1
    Last Post: 08-06-2007, 07:13 PM
  4. Access a variable
    By Eric in forum New To Java
    Replies: 2
    Last Post: 07-04-2007, 08:29 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •