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


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

in Table To:


© 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