Getters Setters with user input












1















Is using getters and setters with userinput a good practice? I looked for some example but was not able to find any. While the code below works but is this a good practice? I noticed If I use the code below I am not able to use constructor. Thank You for your explanation.



public class Tests{

private String name;
private int id;

Scanner userinput = new Scanner(System.in);

public void setName(){
System.out.println("Enter a name: ");
name= userinput.next();
}

public String getName(){

return name;
}

public void displayInfo(){
setName();
System.out.println("You entered " + this.getName());
}
public static void main(String args){

Tests test = new Tests();
test.displayInfo();

}

}









share|improve this question























  • do you want the program to stop while it waits for user input on the command line when your setter is called?

    – 4dc0
    Nov 24 '18 at 7:39











  • Not able to use the constructor? What do you mean?

    – Nicholas K
    Nov 24 '18 at 7:40








  • 2





    No that is not good practice, a set method should have a parameter with the new value to set for the field. In general your data (id, name) should be in one class and gathering of the data should be handled by another class.

    – Joakim Danielson
    Nov 24 '18 at 7:40













  • If I use constructor then, Tests test = new Tests(name, id); I have to type a name/id. However I want the user to be able to supply that name and ID.

    – Sheikh Rahman
    Nov 24 '18 at 7:44











  • @SheikhRahman see my comment above for that issue

    – Joakim Danielson
    Nov 24 '18 at 7:45
















1















Is using getters and setters with userinput a good practice? I looked for some example but was not able to find any. While the code below works but is this a good practice? I noticed If I use the code below I am not able to use constructor. Thank You for your explanation.



public class Tests{

private String name;
private int id;

Scanner userinput = new Scanner(System.in);

public void setName(){
System.out.println("Enter a name: ");
name= userinput.next();
}

public String getName(){

return name;
}

public void displayInfo(){
setName();
System.out.println("You entered " + this.getName());
}
public static void main(String args){

Tests test = new Tests();
test.displayInfo();

}

}









share|improve this question























  • do you want the program to stop while it waits for user input on the command line when your setter is called?

    – 4dc0
    Nov 24 '18 at 7:39











  • Not able to use the constructor? What do you mean?

    – Nicholas K
    Nov 24 '18 at 7:40








  • 2





    No that is not good practice, a set method should have a parameter with the new value to set for the field. In general your data (id, name) should be in one class and gathering of the data should be handled by another class.

    – Joakim Danielson
    Nov 24 '18 at 7:40













  • If I use constructor then, Tests test = new Tests(name, id); I have to type a name/id. However I want the user to be able to supply that name and ID.

    – Sheikh Rahman
    Nov 24 '18 at 7:44











  • @SheikhRahman see my comment above for that issue

    – Joakim Danielson
    Nov 24 '18 at 7:45














1












1








1


1






Is using getters and setters with userinput a good practice? I looked for some example but was not able to find any. While the code below works but is this a good practice? I noticed If I use the code below I am not able to use constructor. Thank You for your explanation.



public class Tests{

private String name;
private int id;

Scanner userinput = new Scanner(System.in);

public void setName(){
System.out.println("Enter a name: ");
name= userinput.next();
}

public String getName(){

return name;
}

public void displayInfo(){
setName();
System.out.println("You entered " + this.getName());
}
public static void main(String args){

Tests test = new Tests();
test.displayInfo();

}

}









share|improve this question














Is using getters and setters with userinput a good practice? I looked for some example but was not able to find any. While the code below works but is this a good practice? I noticed If I use the code below I am not able to use constructor. Thank You for your explanation.



public class Tests{

private String name;
private int id;

Scanner userinput = new Scanner(System.in);

public void setName(){
System.out.println("Enter a name: ");
name= userinput.next();
}

public String getName(){

return name;
}

public void displayInfo(){
setName();
System.out.println("You entered " + this.getName());
}
public static void main(String args){

Tests test = new Tests();
test.displayInfo();

}

}






java getter






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 24 '18 at 7:37









Sheikh RahmanSheikh Rahman

148210




148210













  • do you want the program to stop while it waits for user input on the command line when your setter is called?

    – 4dc0
    Nov 24 '18 at 7:39











  • Not able to use the constructor? What do you mean?

    – Nicholas K
    Nov 24 '18 at 7:40








  • 2





    No that is not good practice, a set method should have a parameter with the new value to set for the field. In general your data (id, name) should be in one class and gathering of the data should be handled by another class.

    – Joakim Danielson
    Nov 24 '18 at 7:40













  • If I use constructor then, Tests test = new Tests(name, id); I have to type a name/id. However I want the user to be able to supply that name and ID.

    – Sheikh Rahman
    Nov 24 '18 at 7:44











  • @SheikhRahman see my comment above for that issue

    – Joakim Danielson
    Nov 24 '18 at 7:45



















  • do you want the program to stop while it waits for user input on the command line when your setter is called?

    – 4dc0
    Nov 24 '18 at 7:39











  • Not able to use the constructor? What do you mean?

    – Nicholas K
    Nov 24 '18 at 7:40








  • 2





    No that is not good practice, a set method should have a parameter with the new value to set for the field. In general your data (id, name) should be in one class and gathering of the data should be handled by another class.

    – Joakim Danielson
    Nov 24 '18 at 7:40













  • If I use constructor then, Tests test = new Tests(name, id); I have to type a name/id. However I want the user to be able to supply that name and ID.

    – Sheikh Rahman
    Nov 24 '18 at 7:44











  • @SheikhRahman see my comment above for that issue

    – Joakim Danielson
    Nov 24 '18 at 7:45

















do you want the program to stop while it waits for user input on the command line when your setter is called?

– 4dc0
Nov 24 '18 at 7:39





do you want the program to stop while it waits for user input on the command line when your setter is called?

– 4dc0
Nov 24 '18 at 7:39













Not able to use the constructor? What do you mean?

– Nicholas K
Nov 24 '18 at 7:40







Not able to use the constructor? What do you mean?

– Nicholas K
Nov 24 '18 at 7:40






2




2





No that is not good practice, a set method should have a parameter with the new value to set for the field. In general your data (id, name) should be in one class and gathering of the data should be handled by another class.

– Joakim Danielson
Nov 24 '18 at 7:40







No that is not good practice, a set method should have a parameter with the new value to set for the field. In general your data (id, name) should be in one class and gathering of the data should be handled by another class.

– Joakim Danielson
Nov 24 '18 at 7:40















If I use constructor then, Tests test = new Tests(name, id); I have to type a name/id. However I want the user to be able to supply that name and ID.

– Sheikh Rahman
Nov 24 '18 at 7:44





If I use constructor then, Tests test = new Tests(name, id); I have to type a name/id. However I want the user to be able to supply that name and ID.

– Sheikh Rahman
Nov 24 '18 at 7:44













@SheikhRahman see my comment above for that issue

– Joakim Danielson
Nov 24 '18 at 7:45





@SheikhRahman see my comment above for that issue

– Joakim Danielson
Nov 24 '18 at 7:45












3 Answers
3






active

oldest

votes


















2














I think your one is not good practice. You can follow this one. Take input in main function and then set input value to name using



public void setName( String name){
this.name =name;
}


Or you can use another method like takeInput(){} and call it from main method and then set in setter method. Like this



public static void main(String args){
Tests tests= new Tests();
String inputString =tests.takeInput();
tests.setName(inputString);
tests.displayInfo();
}


And takeInput() will like this



public String takeInput(){
System.out.println("Enter your name");
String str =userinput.next();
return str;
}


displayInfo() simply display data



And you are already using a constructor when creating Test class object. This is called default constructor. You can also define parameterized constructor like



Tests(String name){
this.name = name;
}


But in this case you don't need to declare parameterized constructor.



And for more better design you can create another class like Info.java where you can define class members like name and its getter and setter and can use Tests class only for main method.






share|improve this answer


























  • This will not compile, you're mixing static and non-static methods in an incorrect way and keywords are missing. Please clean up you code (and also add some indentation) so this answer reaches an acceptable level.

    – Joakim Danielson
    Nov 24 '18 at 13:27













  • Here I explained scenerio. Not giving exact code. This question for analysis not for code running. Thats why i think its not concern

    – flopcoder
    Nov 24 '18 at 14:43











  • This answer might be helpful or a guidance for other beginners since it is marked as accepted so making it as correct as possible is important in my opinion to avoid unnecessary confusion. Besides, don’t you put some pride in your effort and want it to be as good as possible?

    – Joakim Danielson
    Nov 24 '18 at 14:52











  • Sure i will update. I gave this answer from mobile. When i will get access of laptop i will update. Thanks for your concern.

    – flopcoder
    Nov 24 '18 at 14:54



















3














I would say this is terrible practice. It violates the "bean" contract, and it doesn't follow the single responsibility principle (it mutates and prompts for a value). This,



public void setName(){
System.out.println("Enter a name: ");
name= userinput.next();
}


Should just be



public void setName(String name){
this.name = name;
}


And then (don't make Scanner a field for no reason) something like



public void displayInfo() {
Scanner userinput = new Scanner(System.in);
System.out.println("Enter a name: ");
setName(userinput.nextLine());
System.out.println("You entered " + this.getName());
}





share|improve this answer































    1














    I suggest you to change the setName() method with 1 parameter. It will be cleanand will help to be away from many bugs. And you have to do some changes to getName() method. And remove the scanner in the class decleration.



            //setName
    public void setName(String n) {
    this.name = n;
    }

    //getName
    public String getName() {
    return this.name;
    }

    //main method.
    public static void main(String args) {
    Scanner s = new Scanner(System.in);
    Test test = new Test();
    test.setName(s.next());
    test.displayInfo();
    }





    share|improve this answer

























      Your Answer






      StackExchange.ifUsing("editor", function () {
      StackExchange.using("externalEditor", function () {
      StackExchange.using("snippets", function () {
      StackExchange.snippets.init();
      });
      });
      }, "code-snippets");

      StackExchange.ready(function() {
      var channelOptions = {
      tags: "".split(" "),
      id: "1"
      };
      initTagRenderer("".split(" "), "".split(" "), channelOptions);

      StackExchange.using("externalEditor", function() {
      // Have to fire editor after snippets, if snippets enabled
      if (StackExchange.settings.snippets.snippetsEnabled) {
      StackExchange.using("snippets", function() {
      createEditor();
      });
      }
      else {
      createEditor();
      }
      });

      function createEditor() {
      StackExchange.prepareEditor({
      heartbeatType: 'answer',
      autoActivateHeartbeat: false,
      convertImagesToLinks: true,
      noModals: true,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: 10,
      bindNavPrevention: true,
      postfix: "",
      imageUploader: {
      brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
      contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
      allowUrls: true
      },
      onDemand: true,
      discardSelector: ".discard-answer"
      ,immediatelyShowMarkdownHelp:true
      });


      }
      });














      draft saved

      draft discarded


















      StackExchange.ready(
      function () {
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53456155%2fgetters-setters-with-user-input%23new-answer', 'question_page');
      }
      );

      Post as a guest















      Required, but never shown

























      3 Answers
      3






      active

      oldest

      votes








      3 Answers
      3






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes









      2














      I think your one is not good practice. You can follow this one. Take input in main function and then set input value to name using



      public void setName( String name){
      this.name =name;
      }


      Or you can use another method like takeInput(){} and call it from main method and then set in setter method. Like this



      public static void main(String args){
      Tests tests= new Tests();
      String inputString =tests.takeInput();
      tests.setName(inputString);
      tests.displayInfo();
      }


      And takeInput() will like this



      public String takeInput(){
      System.out.println("Enter your name");
      String str =userinput.next();
      return str;
      }


      displayInfo() simply display data



      And you are already using a constructor when creating Test class object. This is called default constructor. You can also define parameterized constructor like



      Tests(String name){
      this.name = name;
      }


      But in this case you don't need to declare parameterized constructor.



      And for more better design you can create another class like Info.java where you can define class members like name and its getter and setter and can use Tests class only for main method.






      share|improve this answer


























      • This will not compile, you're mixing static and non-static methods in an incorrect way and keywords are missing. Please clean up you code (and also add some indentation) so this answer reaches an acceptable level.

        – Joakim Danielson
        Nov 24 '18 at 13:27













      • Here I explained scenerio. Not giving exact code. This question for analysis not for code running. Thats why i think its not concern

        – flopcoder
        Nov 24 '18 at 14:43











      • This answer might be helpful or a guidance for other beginners since it is marked as accepted so making it as correct as possible is important in my opinion to avoid unnecessary confusion. Besides, don’t you put some pride in your effort and want it to be as good as possible?

        – Joakim Danielson
        Nov 24 '18 at 14:52











      • Sure i will update. I gave this answer from mobile. When i will get access of laptop i will update. Thanks for your concern.

        – flopcoder
        Nov 24 '18 at 14:54
















      2














      I think your one is not good practice. You can follow this one. Take input in main function and then set input value to name using



      public void setName( String name){
      this.name =name;
      }


      Or you can use another method like takeInput(){} and call it from main method and then set in setter method. Like this



      public static void main(String args){
      Tests tests= new Tests();
      String inputString =tests.takeInput();
      tests.setName(inputString);
      tests.displayInfo();
      }


      And takeInput() will like this



      public String takeInput(){
      System.out.println("Enter your name");
      String str =userinput.next();
      return str;
      }


      displayInfo() simply display data



      And you are already using a constructor when creating Test class object. This is called default constructor. You can also define parameterized constructor like



      Tests(String name){
      this.name = name;
      }


      But in this case you don't need to declare parameterized constructor.



      And for more better design you can create another class like Info.java where you can define class members like name and its getter and setter and can use Tests class only for main method.






      share|improve this answer


























      • This will not compile, you're mixing static and non-static methods in an incorrect way and keywords are missing. Please clean up you code (and also add some indentation) so this answer reaches an acceptable level.

        – Joakim Danielson
        Nov 24 '18 at 13:27













      • Here I explained scenerio. Not giving exact code. This question for analysis not for code running. Thats why i think its not concern

        – flopcoder
        Nov 24 '18 at 14:43











      • This answer might be helpful or a guidance for other beginners since it is marked as accepted so making it as correct as possible is important in my opinion to avoid unnecessary confusion. Besides, don’t you put some pride in your effort and want it to be as good as possible?

        – Joakim Danielson
        Nov 24 '18 at 14:52











      • Sure i will update. I gave this answer from mobile. When i will get access of laptop i will update. Thanks for your concern.

        – flopcoder
        Nov 24 '18 at 14:54














      2












      2








      2







      I think your one is not good practice. You can follow this one. Take input in main function and then set input value to name using



      public void setName( String name){
      this.name =name;
      }


      Or you can use another method like takeInput(){} and call it from main method and then set in setter method. Like this



      public static void main(String args){
      Tests tests= new Tests();
      String inputString =tests.takeInput();
      tests.setName(inputString);
      tests.displayInfo();
      }


      And takeInput() will like this



      public String takeInput(){
      System.out.println("Enter your name");
      String str =userinput.next();
      return str;
      }


      displayInfo() simply display data



      And you are already using a constructor when creating Test class object. This is called default constructor. You can also define parameterized constructor like



      Tests(String name){
      this.name = name;
      }


      But in this case you don't need to declare parameterized constructor.



      And for more better design you can create another class like Info.java where you can define class members like name and its getter and setter and can use Tests class only for main method.






      share|improve this answer















      I think your one is not good practice. You can follow this one. Take input in main function and then set input value to name using



      public void setName( String name){
      this.name =name;
      }


      Or you can use another method like takeInput(){} and call it from main method and then set in setter method. Like this



      public static void main(String args){
      Tests tests= new Tests();
      String inputString =tests.takeInput();
      tests.setName(inputString);
      tests.displayInfo();
      }


      And takeInput() will like this



      public String takeInput(){
      System.out.println("Enter your name");
      String str =userinput.next();
      return str;
      }


      displayInfo() simply display data



      And you are already using a constructor when creating Test class object. This is called default constructor. You can also define parameterized constructor like



      Tests(String name){
      this.name = name;
      }


      But in this case you don't need to declare parameterized constructor.



      And for more better design you can create another class like Info.java where you can define class members like name and its getter and setter and can use Tests class only for main method.







      share|improve this answer














      share|improve this answer



      share|improve this answer








      edited Nov 24 '18 at 14:59

























      answered Nov 24 '18 at 7:48









      flopcoderflopcoder

      735512




      735512













      • This will not compile, you're mixing static and non-static methods in an incorrect way and keywords are missing. Please clean up you code (and also add some indentation) so this answer reaches an acceptable level.

        – Joakim Danielson
        Nov 24 '18 at 13:27













      • Here I explained scenerio. Not giving exact code. This question for analysis not for code running. Thats why i think its not concern

        – flopcoder
        Nov 24 '18 at 14:43











      • This answer might be helpful or a guidance for other beginners since it is marked as accepted so making it as correct as possible is important in my opinion to avoid unnecessary confusion. Besides, don’t you put some pride in your effort and want it to be as good as possible?

        – Joakim Danielson
        Nov 24 '18 at 14:52











      • Sure i will update. I gave this answer from mobile. When i will get access of laptop i will update. Thanks for your concern.

        – flopcoder
        Nov 24 '18 at 14:54



















      • This will not compile, you're mixing static and non-static methods in an incorrect way and keywords are missing. Please clean up you code (and also add some indentation) so this answer reaches an acceptable level.

        – Joakim Danielson
        Nov 24 '18 at 13:27













      • Here I explained scenerio. Not giving exact code. This question for analysis not for code running. Thats why i think its not concern

        – flopcoder
        Nov 24 '18 at 14:43











      • This answer might be helpful or a guidance for other beginners since it is marked as accepted so making it as correct as possible is important in my opinion to avoid unnecessary confusion. Besides, don’t you put some pride in your effort and want it to be as good as possible?

        – Joakim Danielson
        Nov 24 '18 at 14:52











      • Sure i will update. I gave this answer from mobile. When i will get access of laptop i will update. Thanks for your concern.

        – flopcoder
        Nov 24 '18 at 14:54

















      This will not compile, you're mixing static and non-static methods in an incorrect way and keywords are missing. Please clean up you code (and also add some indentation) so this answer reaches an acceptable level.

      – Joakim Danielson
      Nov 24 '18 at 13:27







      This will not compile, you're mixing static and non-static methods in an incorrect way and keywords are missing. Please clean up you code (and also add some indentation) so this answer reaches an acceptable level.

      – Joakim Danielson
      Nov 24 '18 at 13:27















      Here I explained scenerio. Not giving exact code. This question for analysis not for code running. Thats why i think its not concern

      – flopcoder
      Nov 24 '18 at 14:43





      Here I explained scenerio. Not giving exact code. This question for analysis not for code running. Thats why i think its not concern

      – flopcoder
      Nov 24 '18 at 14:43













      This answer might be helpful or a guidance for other beginners since it is marked as accepted so making it as correct as possible is important in my opinion to avoid unnecessary confusion. Besides, don’t you put some pride in your effort and want it to be as good as possible?

      – Joakim Danielson
      Nov 24 '18 at 14:52





      This answer might be helpful or a guidance for other beginners since it is marked as accepted so making it as correct as possible is important in my opinion to avoid unnecessary confusion. Besides, don’t you put some pride in your effort and want it to be as good as possible?

      – Joakim Danielson
      Nov 24 '18 at 14:52













      Sure i will update. I gave this answer from mobile. When i will get access of laptop i will update. Thanks for your concern.

      – flopcoder
      Nov 24 '18 at 14:54





      Sure i will update. I gave this answer from mobile. When i will get access of laptop i will update. Thanks for your concern.

      – flopcoder
      Nov 24 '18 at 14:54













      3














      I would say this is terrible practice. It violates the "bean" contract, and it doesn't follow the single responsibility principle (it mutates and prompts for a value). This,



      public void setName(){
      System.out.println("Enter a name: ");
      name= userinput.next();
      }


      Should just be



      public void setName(String name){
      this.name = name;
      }


      And then (don't make Scanner a field for no reason) something like



      public void displayInfo() {
      Scanner userinput = new Scanner(System.in);
      System.out.println("Enter a name: ");
      setName(userinput.nextLine());
      System.out.println("You entered " + this.getName());
      }





      share|improve this answer




























        3














        I would say this is terrible practice. It violates the "bean" contract, and it doesn't follow the single responsibility principle (it mutates and prompts for a value). This,



        public void setName(){
        System.out.println("Enter a name: ");
        name= userinput.next();
        }


        Should just be



        public void setName(String name){
        this.name = name;
        }


        And then (don't make Scanner a field for no reason) something like



        public void displayInfo() {
        Scanner userinput = new Scanner(System.in);
        System.out.println("Enter a name: ");
        setName(userinput.nextLine());
        System.out.println("You entered " + this.getName());
        }





        share|improve this answer


























          3












          3








          3







          I would say this is terrible practice. It violates the "bean" contract, and it doesn't follow the single responsibility principle (it mutates and prompts for a value). This,



          public void setName(){
          System.out.println("Enter a name: ");
          name= userinput.next();
          }


          Should just be



          public void setName(String name){
          this.name = name;
          }


          And then (don't make Scanner a field for no reason) something like



          public void displayInfo() {
          Scanner userinput = new Scanner(System.in);
          System.out.println("Enter a name: ");
          setName(userinput.nextLine());
          System.out.println("You entered " + this.getName());
          }





          share|improve this answer













          I would say this is terrible practice. It violates the "bean" contract, and it doesn't follow the single responsibility principle (it mutates and prompts for a value). This,



          public void setName(){
          System.out.println("Enter a name: ");
          name= userinput.next();
          }


          Should just be



          public void setName(String name){
          this.name = name;
          }


          And then (don't make Scanner a field for no reason) something like



          public void displayInfo() {
          Scanner userinput = new Scanner(System.in);
          System.out.println("Enter a name: ");
          setName(userinput.nextLine());
          System.out.println("You entered " + this.getName());
          }






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 24 '18 at 7:44









          Elliott FrischElliott Frisch

          153k1389178




          153k1389178























              1














              I suggest you to change the setName() method with 1 parameter. It will be cleanand will help to be away from many bugs. And you have to do some changes to getName() method. And remove the scanner in the class decleration.



                      //setName
              public void setName(String n) {
              this.name = n;
              }

              //getName
              public String getName() {
              return this.name;
              }

              //main method.
              public static void main(String args) {
              Scanner s = new Scanner(System.in);
              Test test = new Test();
              test.setName(s.next());
              test.displayInfo();
              }





              share|improve this answer






























                1














                I suggest you to change the setName() method with 1 parameter. It will be cleanand will help to be away from many bugs. And you have to do some changes to getName() method. And remove the scanner in the class decleration.



                        //setName
                public void setName(String n) {
                this.name = n;
                }

                //getName
                public String getName() {
                return this.name;
                }

                //main method.
                public static void main(String args) {
                Scanner s = new Scanner(System.in);
                Test test = new Test();
                test.setName(s.next());
                test.displayInfo();
                }





                share|improve this answer




























                  1












                  1








                  1







                  I suggest you to change the setName() method with 1 parameter. It will be cleanand will help to be away from many bugs. And you have to do some changes to getName() method. And remove the scanner in the class decleration.



                          //setName
                  public void setName(String n) {
                  this.name = n;
                  }

                  //getName
                  public String getName() {
                  return this.name;
                  }

                  //main method.
                  public static void main(String args) {
                  Scanner s = new Scanner(System.in);
                  Test test = new Test();
                  test.setName(s.next());
                  test.displayInfo();
                  }





                  share|improve this answer















                  I suggest you to change the setName() method with 1 parameter. It will be cleanand will help to be away from many bugs. And you have to do some changes to getName() method. And remove the scanner in the class decleration.



                          //setName
                  public void setName(String n) {
                  this.name = n;
                  }

                  //getName
                  public String getName() {
                  return this.name;
                  }

                  //main method.
                  public static void main(String args) {
                  Scanner s = new Scanner(System.in);
                  Test test = new Test();
                  test.setName(s.next());
                  test.displayInfo();
                  }






                  share|improve this answer














                  share|improve this answer



                  share|improve this answer








                  edited Nov 24 '18 at 7:55

























                  answered Nov 24 '18 at 7:47









                  Seniru PasanSeniru Pasan

                  95




                  95






























                      draft saved

                      draft discarded




















































                      Thanks for contributing an answer to Stack Overflow!


                      • Please be sure to answer the question. Provide details and share your research!

                      But avoid



                      • Asking for help, clarification, or responding to other answers.

                      • Making statements based on opinion; back them up with references or personal experience.


                      To learn more, see our tips on writing great answers.




                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function () {
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53456155%2fgetters-setters-with-user-input%23new-answer', 'question_page');
                      }
                      );

                      Post as a guest















                      Required, but never shown





















































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown

































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown







                      Popular posts from this blog

                      Contact image not getting when fetch all contact list from iPhone by CNContact

                      count number of partitions of a set with n elements into k subsets

                      A CLEAN and SIMPLE way to add appendices to Table of Contents and bookmarks