Results 1 to 5 of 5
  1. #1
    ineedahero is offline Member
    Join Date
    Dec 2013
    Posts
    3
    Rep Power
    0

    Default How exactly do static variable work?

    Let's say I have a TicTacToe game that can play multiple games concurrently.

    Let's say I have as a static data member "String[] playersWhoArePlaying", that has a length of 100.


    Then, each time I start a game, I, inside the instance of each game, add the names of the two players in the game to this array. After they finish playing, I remove their names from the array.

    Let's say I also, inside each game, use this array to check to see if the people in this current game are also (problematically) playing in another game at the same time.

    Would making this variable "static" actually be enough here?

    I'm asking because I'm doing this exact thing in a program, and the 'playersWhoArePlaying' variable isn't the same for each different instance of the game, despite the fact that it is static.

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,559
    Rep Power
    25

    Default Re: How exactly do static variable work?

    If you don't understand my response, don't ignore it, ask a question.

  3. #3
    ineedahero is offline Member
    Join Date
    Dec 2013
    Posts
    3
    Rep Power
    0

    Default Re: How exactly do static variable work?

    Yeah, for some reason the code on that site messes everything up. I figure that made it look too confusing.

    Also...how do you delete threads on that site? All it does is let you edit them. I can't ever find the delete button.

  4. #4
    GregBrannon is offline Member
    Join Date
    Mar 2013
    Location
    Southern Maryland, USA
    Posts
    5
    Rep Power
    0

    Default Re: How exactly do static variable work?

    I can't ever find the delete button.
    Hmmm. Wonder why . . .

  5. #5
    ineedahero is offline Member
    Join Date
    Dec 2013
    Posts
    3
    Rep Power
    0

    Default Re: How exactly do static variable work?

    ^

    If you hover over "edit" it says "edit / delete"

    I click that, and find no sign of "delete"

Similar Threads

  1. Replies: 2
    Last Post: 04-10-2013, 12:46 AM
  2. Replies: 7
    Last Post: 12-07-2012, 01:00 PM
  3. Replies: 5
    Last Post: 10-15-2010, 04:21 AM
  4. Replies: 3
    Last Post: 02-11-2010, 09:59 AM
  5. Replies: 1
    Last Post: 08-01-2007, 09:25 PM

Posting Permissions

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