Adobe COLDFUSION 9 Manual page 1142

Developing applications
Hide thumbs Also See for COLDFUSION 9:
Table of Contents

Advertisement

DEVELOPING COLDFUSION 9 APPLICATIONS
Using Web Elements and External Objects
Creating and using a simple Java class
Java is a strongly typed language, unlike ColdFusion, which does not enforce data types. As a result, some subtle
considerations exist when calling Java methods.
The Employee class
The Employee class has four data members: FirstName and LastName are public, and Salary and JobGrade are private.
The Employee class has three overloaded constructors and an overloaded SetJobGrade method.
Save the following Java source code in the file Employee.java, compile it, and place the resulting Employee.class file in
a directory that is specified in the classpath:
public class Employee {
public String FirstName;
public String LastName;
private float Salary;
private int JobGrade;
public Employee() {
FirstName ="";
LastName ="";
Salary = 0.0f;
JobGrade = 0;
}
public Employee(String First, String Last) {
FirstName = First;
LastName = Last;
Salary = 0.0f;
JobGrade = 0;
}
public Employee(String First, String Last, float salary, int grade) {
FirstName = First;
LastName = Last;
Salary = salary;
JobGrade = grade;
}
public void SetSalary(float Dollars) {
Salary = Dollars;
}
public float GetSalary() {
return Salary;
}
public void SetJobGrade(int grade) {
Last updated 8/5/2010
1137

Advertisement

Table of Contents
loading

Table of Contents