Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Car {
- private String color;
- Car(String newColor) {
- color = newColor;
- }
- void showColor() {
- System.out.println(this.color);
- }
- }
- Car car1 = new Car("red");
- Car car2 = new Car("blue");
- car1.showColor(); // this -> car1 -> this.color == car1.color
- car2.showColor(); // this -> car2 -> this.color == car2.color
Add Comment
Please, Sign In to add comment