Provide yourself an example (not one from your instructor) of how you use a particular command that will help jog your memory in the future when you need that command again. You must provide a little code as well as a written explanation with this one.
The equal sign in Java is used for assignments. It is really crucial to know the difference between the = sign in Mathematics and Java. In Math, the two things that are set equal have exactly the same value and no assignment is done. However, in Java, the entity to the right of the = sign is assigned to the entity on the left side.
Example:
public SimpleCalculator(double x, double y)
{
sumTotal = x;
productTotal = y;
}
//is very different from:
public SimpleCalculator(double x, double y)
{
x = sumTotal;
y = productTotal;
}
On the first one, the x and y values are assigned to the sumTotal and productTotal values. But in the second one, the reverse is done. So it is very important to know the real meaning of the "assigner" in Java.
Tuesday, October 9, 2007
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment