Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa Java-Beginners how to set values in object using java and what are the ways?

Have Programming Question? Ask it here!
 
 
 


keerthana rani
how to set values in object using java and what are the ways?
2 Answer(s)      3 years and 5 months ago
Posted in : Java Beginners


How to set values in object using java ?what are the ways


Advertisement
View Answers

April 2, 2011 at 12:29 PM


Hi You can set the value the object Using Setter Getter Methods. Please create the Setter Getter method for all the field in which you have to set the value. Example -

public class Test{ private int num;

// This method sets the value to the variable of the object public void setNum(int num){ this.num=nym; }

// This method will Return the value of the objetc. public int getNum(){ return this.num; } }

IDE Eclipse provides a very simple way to do this. In Eclipse do the following

  1. Open the class in which you have to generate setter gettre methods

  2. Go tho the "Source" Menu And click on the Generate Setter Getter method



April 2, 2011 at 12:34 PM


Hi You can set the value the object Using Setter Getter Methods. Please create the Setter Getter method for all the field in which you have to set the value. Example -

public class Test{ 
 private int num;

// This method sets the value to the variable of the object  public void 
setNum(int num){ 
 this.num=nym;
}

// This method will Return the value of the objetc. public int getNum(){
 return this.num;
 }
}

IDE Eclipse provides a very simple way to do this. In Eclipse do the following

Open the class in which you have to generate setter gettre methods

Go tho the "Source" Menu And click on the Generate Setter Getter method



Related Tutorials/Questions & Answers:
Advertisements
 

 

 

DMCA.com