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

Ads
 

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

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

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

Ads









Related Tutorials/Questions & Answers:
how to set values in object using java and what are the ways?
How to store unique values in Java using Set?
Advertisements
How to store unique values in Java using Set?
how to set the values in jsp
How to values from xml using java?
how to show set of images continously using JScrollpane in java
how to show set of images continously using JScrollpane in java
how to store the REsult Set values in array and loop through it in java?
how to store the REsult Set values in array and loop through it in java?
How to insert dynamic textbox values into database using Java?
Java Swing Set And Get Values
how to update values of a html form into an excel table using java servlets?
how to load values of html form into an excel table using java servlet?
how to Insert Array Values Into Separate Rows using java?
How to set CLASSPATH in Java?
remove duplicates from list in java using set
what is mutable and immutable object in java ?difference ?
how can i set an object in focus
How to show database values into graph using jsp?
How to show database values into graph using jsp?
How to set attachment from browse button to send mails using java mail api
how to store multiple values from drop down in database where i am using java struts 1.3
How to create bar chart using database values
How to get Keys and Values from HashMap in Java?
how to get session object in simple java class??
Java using Netbeans Object Oriented Programming
Object reference not set to an instance of an object
how to read values from java in xml?
How to access sub class member using super class object
Import object in Excel using java swing
In Java how to get size of class and object?

Ads