Basic HTML version of Foils prepared May 19 99

Foil 11 Our first example of Writing a Bean: HelloBean!

From Javabeans Basic Information Track Computational Science Course CPS616 -- Spring Semester 1999. by Geoffrey Fox, Nancy McCracken, Wojtek Furmanski


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



© Northeast Parallel Architectures Center, Syracuse University, npac@npac.syr.edu

If you have any comments about this server, send e-mail to webmaster@npac.syr.edu.

Page produced by wwwfoil on Mon Jul 5 1999