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

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 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?
how to show set of images continously using JScrollpane in java
how to show set of images continously using JScrollpane in 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 can i set an object in focus
remove duplicates from list in java using set
How to show database values into graph using jsp?
How to show database values into graph using jsp?
Object reference not set to an instance of an object
How to set CLASSPATH in Java?
How to set a variable value using velocity
How to create bar chart using database values
what is mutable and immutable object in java ?difference ?
How to get Keys and Values from HashMap in Java?
how to store multiple values from drop down in database where i am using java struts 1.3
How to set attachment from browse button to send mails using java mail api
Java using Netbeans Object Oriented Programming
How to insert data from a combobox and textbox values into DB using JSP?
how to generate automatic bill based on selected values using jsp/javascript?
how to read values from excel sheet and compare with database using jsp
Set Textbox in PowerPoint Slide Using Java
Import object in Excel using java swing
how to display values from database into table using jsp
How to access sub class member using super class object
How to make addition of two combobox values using jsp and javascript?
What is Light Object Mapping?
How to parse the attributes values from XML using KXML parser in j2me
how to get session object in simple java class??
how to access the object of one frame on clicking a button without using this keyword
how to read values from java in xml?
What is an object's lock and which object's have locks?
Set Timestamp by using the Prepared Statement
In Java how to get size of class and object?
In Java how to get size of class and object?
Java Method Return Multiple Values
How to set a microsoft word document PASSWORD by using Visual Basic 2008 express?
How to set the border in header and footer from login page using swings/awt
how to set class path
how to generate a bar chart on a JSP PAGE using the arraylist object passed form the servlet.(using jfreechart)
How to read a rows which have a values in a excel file using apache poi - JSP-Servlet

Ads