Page 3 of 3 FirstFirst 123
Results 41 to 44 of 44
  1. #41
    cjburkey01 is offline Member
    Join Date
    Dec 2013
    Posts
    70
    Rep Power
    0

    Default Re: Variable Is Set, Works, But Then In Void, Returns 0

    I actually made a file like this:
    Java Code:
    Boss at life
    6
    1
    0 1 2 3 4 5
    And it gives 5 for all the things, it returns 5 5 5 5 5 and makes the block looks like a flag(id 5)

  2. #42
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,884
    Rep Power
    25

    Default Re: Variable Is Set, Works, But Then In Void, Returns 0

    it returns 5 5 5 5 5
    Are you saying that ALL of the instances of the Block class have the same value:5 for the variable id? And that the value of id is the LAST value that was assigned to it?

    Do you know what a static variable is?
    If you don't understand my response, don't ignore it, ask a question.

  3. #43
    cjburkey01 is offline Member
    Join Date
    Dec 2013
    Posts
    70
    Rep Power
    0

    Default Re: Variable Is Set, Works, But Then In Void, Returns 0

    I'm not entirely aware of what a static variable is, but if I'm using the same code I was 2 days ago, and it worked then, why doesn't it work now?

  4. #44
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,884
    Rep Power
    25

    Default Re: Variable Is Set, Works, But Then In Void, Returns 0

    If EVERYTHING was the same, the program should do the same thing.

    Why is id static?
    If you don't understand my response, don't ignore it, ask a question.

Page 3 of 3 FirstFirst 123

Similar Threads

  1. Replies: 18
    Last Post: 03-26-2014, 11:43 PM
  2. Please explain static void and void methods are ?
    By shavindra in forum New To Java
    Replies: 5
    Last Post: 01-10-2013, 09:46 PM
  3. accessing variables in a method that returns a void
    By mochajava in forum New To Java
    Replies: 2
    Last Post: 02-12-2011, 09:00 PM
  4. Replies: 5
    Last Post: 01-25-2008, 12:53 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
  •