November 2004
Intermediate to advanced
1024 pages
27h 50m
English
All the native methods that you saw so far were static methods with number and string parameters. We next consider native methods that operate on objects. As an exercise, we implement a method of the Employee class that was introduced in Volume 1, Chapter 4, using a native method. Again, this is not something you would normally want to do, but it does illustrate how to access fields from a native method when you need to do so.
In order to see how to access instance fields from a native method, we will reimplement the raiseSalary method. In the Java programming language, the code was simple.
public void raiseSalary(double byPercent)
{
salary *= 1 + byPercent / 100;
}
Let us rewrite this as a native ...
Read now
Unlock full access