Java Reference
In-Depth Information
Figure 6-11 shows the alternative formula solution.
Figure 6-11.
11.
Run Employee as a Java application.
The results in the console should be:
64.5
89.5
244.4
36.0
9.6
Tutorial: Comparisons between Reference Variables
Comparing primitive variables is easy. Comparing reference variables is a little more complicated. Remember,
reference variables contain memory addresses not data. So, when comparing two reference variables, they must
both point to the same object in storage. We will use Employee variables first and then String variables to drive this
concept home.
1.
Create a new Java class in c6 called StringCompApp that has a main method stub.
2.
Enter the following statements in the main method to define two Employee objects
and variables:
Employee emp1 = new Employee("Joe","1 Main St.","","","");
Employee emp2 = new Employee("Joe","1 Main St.","","","");
 
Search WWH ::




Custom Search