Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
- package ja10;
- public class JA10 {
- /**
- * @param args the command line arguments
- */
- public static void main(String[] args) {
- // TODO code application logic here
- // объявляем переменную типа Car
- Car c1;
- Car c2;
- // создаем объекта типа Car
- // используем ключевое слово new для создания объекта
- // переменной c1 присваиваем объект типа Car
- c1 = new Car();
- // объявляем переменную c3 и присваиваем объект типа Car
- Car c3 = new Car();
- // вызываем метод setColor для установки цвета авто c3
- // для вызова метода - используем оператор .
- c3.setColor("green"); // устанавливаем красный цвет для авто c3
- // выводим на экран цвет авто c3
- String color1 = c3.getColor();
- System.out.println("color1=" + color1);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement