To a standard hello world Java class, we add a (read/write) property by defining get and set functions in the correct pattern. |
import java.awt.* |
public class HelloBean extends java.applet.Applet |
implements java.io.Serializable |
{ String sname = "World"; |
public void setName (String newname) |
{ sname = newname; } |
public String getName ( ) |
{ return sname; } |
Enables saving as Object |
Instance variable for value of property (not available outside the class) |
Get and set methods define a property called "name" with a value of type String |