Skip to main content

Re Java Beans

1 reply [Last post]
imran547
Offline
Joined: 2010-03-03
Points: 0

As-salamwalaikum 2 all javas. I am new to this site. I want to know how to create java beans progrm without net beans and eclipse.
Software java jdk1.6.0, bdk1.1.

Please help guys.

thankz

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
tejesh
Offline
Joined: 2006-05-05
Points: 0

create java beans progrm without net beans and eclipse:

For suppose if you have the following props,
id,name, price;

(1)The basic rule is need to have setters and getters for all the properties.
(2) The method names should follow the Java conventions. If you follow the conventions then we will get some extra functionalities provided by some frameworks.

Please check the sample code.

public class Product {
private int id;
private String name;
private float price;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public float getPrice() {
return price;
}
public void setPrice(float price) {
this.price = price;
}

public String execute(){
return "success";
}
}