Explain the Member Access Separator ?
class Car {
String licensePlate; // e.g. "New York 543 A23"
double speed; // in kilometers per hour
double maxSpeed; // in kilometers per hour
}
Once you've constructed a car, you need to do something along with it. To access the fields of the car you use the . separator. The Car class has three fields
• licensePlate
• speed
• maxSpeed
Thus if c is a Car object, c has three fields as well:
• c.licensePlate
• c.speed
• c.maxSpeed
You use these only like you'd use any other variables of the similar type. For example:
Car c = new Car();
c.licensePlate = "New York A45 636";
c.speed = 70.0;
c.maxSpeed = 123.45;
System.out.println(c.licensePlate + " is moving at " + c.speed +
"kilometers per hour.");
The . separator selects a exact member of a Car object through name.