Advertisement
sergAccount

Untitled

Dec 19th, 2020
1,262
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.34 KB | None | 0 0
  1. /*
  2.  * To change this license header, choose License Headers in Project Properties.
  3.  * To change this template file, choose Tools | Templates
  4.  * and open the template in the editor.
  5.  */
  6. package ja10;
  7.  
  8. public class JA10 {
  9.  
  10.     /**
  11.      * @param args the command line arguments
  12.      */
  13.     public static void main(String[] args) {
  14.         // TODO code application logic here
  15.         // объявляем переменную типа Car
  16.         Car c1;
  17.         Car c2;
  18.         // создаем объекта типа Car
  19.         // используем ключевое слово new для создания объекта
  20.         // переменной c1 присваиваем объект типа Car
  21.         c1 = new Car();
  22.         // объявляем переменную c3 и присваиваем объект типа Car
  23.         Car c3 = new Car();        
  24.         // вызываем метод setColor для установки цвета авто c3
  25.         // для вызова метода - используем оператор .
  26.         c3.setColor("green"); // устанавливаем красный цвет для авто c3
  27.         // выводим на экран цвет авто c3
  28.         String color1 = c3.getColor();
  29.         System.out.println("color1=" + color1);
  30.        
  31.     }    
  32. }
  33.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement