Results 1 to 5 of 5
  1. #1
    A.M.S is offline Member
    Join Date
    Dec 2008
    Posts
    17
    Rep Power
    0

    Exclamation Constructors, Setter & Getter << need some explaining

    Hi everyone,
    I'm a new 2 java programming, I've started study it 2 months ago in my college (Computer Science) ..

    I've a problem with Setter & Getter, they're not clear !
    when I use them ? and why ? (with some examples plz)


    I hope anyone help me ,,

    (Sorry about my bad English) :D

  2. #2
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

  3. #3
    A.M.S is offline Member
    Join Date
    Dec 2008
    Posts
    17
    Rep Power
    0

    Default

    thanks Eranga,

    But what's the difference if I use any method and in its end I write return Value ?

  4. #4
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

    Default

    In simple word it's all about encapsulation, safety for the code from others change. You are get the input from the setter method and return the values from getter, and all the processing done on different methods. Normally those methods have higher restriction in access, private in most of the cases.

  5. #5
    A.M.S is offline Member
    Join Date
    Dec 2008
    Posts
    17
    Rep Power
    0

Similar Threads

  1. problem in getter method
    By freddieMaize in forum Advanced Java
    Replies: 5
    Last Post: 05-26-2008, 07:02 AM
  2. Help with constructors
    By Minime in forum New To Java
    Replies: 3
    Last Post: 04-09-2008, 07:59 AM
  3. Initializing variables using constructors
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 01-13-2008, 08:28 PM
  4. constructors
    By khamuruddeen in forum New To Java
    Replies: 2
    Last Post: 12-01-2007, 03:15 PM
  5. How To Add Fields And Generating Getter-Setters
    By JavaForums in forum NetBeans
    Replies: 0
    Last Post: 07-30-2007, 11:13 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
  •