Basic HTML version of Foils prepared March 23 98

Foil 10 Our first example: HelloBean!

From JavaBeans and Use in ComponentWare Basic Information Track Computational Science Course CPS616 -- March 25 1998. by Nancy McCracken, Geoffrey C. Fox, 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
Class variable for value of property
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 Sun Nov 29 1998