Results 1 to 7 of 7

Thread: [RESOLVED] access control "private"

  1. #1

    Thread Starter
    PowerPoster eranga262154's Avatar
    Join Date
    Jun 2006
    Posts
    2,201

    Resolved [RESOLVED] access control "private"

    Let say I have a private instance variable in a Java code.

    Code:
    class SetName
           {
                 private String Name;
     
                 // rest of the code goes here
          }
    Is there any direct/indirect way to retrieve or set its value from other classes.
    “victory breeds hatred, the defeated live in pain; happily the peaceful live giving up victory and defeat” - Gautama Buddha

  2. #2
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594

    Re: access control "private"

    Indirect, yes: define a setter. But the whole point of private variables is that they can't be accessed from other classes.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  3. #3

    Thread Starter
    PowerPoster eranga262154's Avatar
    Join Date
    Jun 2006
    Posts
    2,201

    Re: access control "private"

    How about the methods such as void, no return value.
    “victory breeds hatred, the defeated live in pain; happily the peaceful live giving up victory and defeat” - Gautama Buddha

  4. #4
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594

    Re: access control "private"

    What's the question?
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  5. #5

    Thread Starter
    PowerPoster eranga262154's Avatar
    Join Date
    Jun 2006
    Posts
    2,201

    Re: access control "private"

    I mean how can work on such a variable on a method like void which has no return value.
    “victory breeds hatred, the defeated live in pain; happily the peaceful live giving up victory and defeat” - Gautama Buddha

  6. #6
    Addicted Member TBeck's Avatar
    Join Date
    Apr 2006
    Location
    Ontario, Canada
    Posts
    254

    Re: access control "private"

    the void methods are used to manipulate the private instance variables of the class

  7. #7

    Thread Starter
    PowerPoster eranga262154's Avatar
    Join Date
    Jun 2006
    Posts
    2,201

    Re: access control "private"

    How poor I'm to miss this point. Thanks
    “victory breeds hatred, the defeated live in pain; happily the peaceful live giving up victory and defeat” - Gautama Buddha

Posting Permissions

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



Click Here to Expand Forum to Full Width