
1137
DEVELOPING
COLDFUSION 9 APPLICATIONS
Using Web Elements and External Objects
Las
t
upda
te
d 8/5/2010
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) {
Содержание COLDFUSION 9
Страница 1: ...Developing Applications ADOBE COLDFUSION 9...