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









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?
Java Swing Set And Get Values
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
How to set background of an excel sheet using POI - Java Magazine
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 can i set an object in focus
how to Insert Array Values Into Separate Rows using java?
how to set values from parent page to iframe in javascript
Java generate the powerset of a given set
What are the methods in Object? - Java Beginners
remove duplicates from list in java using set
Object reference not set to an instance of an object
How to show database values into graph using jsp?
How to show database values into graph using jsp?
what is mutable and immutable object in java ?difference ?
How to set CLASSPATH in Java?
How to set a variable value using velocity
How to create bar chart using database values
set the arraylist values - Struts
Java using Netbeans Object Oriented Programming
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
How to get Keys and Values from HashMap in Java?
Set Textbox in PowerPoint Slide Using Java
How can we find the number of rows in a result set using PHP?
Import object in Excel using java swing
what is Set Transaction?
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?
Date object using JavaScript
how to set break in jasper report using ireport - JSP-Servlet
What is Light Object Mapping?
how to convert xml string to soap request object using axis1.4?
how to set image in button using swing? - Swing AWT
how to read values from excel sheet and compare with database using jsp
How to store values in a database using JSTL? - JSP-Servlet
how to display values from database into table using jsp
How to access sub class member using super class object
How to edit values in textboxes from database using jsp
what is object chaining? - Hibernate
What is an object's lock and which object's have locks?

Ads