A member variable is a variable that belongs to an object, whereas a local variable belongs to the current scope.
class MoterVehicle{
String licensePlate = ""; // member variable
double speed; = 0.0; // member variable
double maxSpeed; = 123.45; // member variable
boolean isSpeeding() {
double excess; // local variable
excess = this.maxSpeed - this.speed;
if (excess < 0) return true;
else return false;
}
}
class MoterVehicle{
String licensePlate = ""; // member variable
double speed; = 0.0; // member variable
double maxSpeed; = 123.45; // member variable
boolean isSpeeding() {
double excess; // local variable
excess = this.maxSpeed - this.speed;
if (excess < 0) return true;
else return false;
}
}
No comments:
Post a Comment