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 com.mycompany.ex19;
- /**
- *
- * @author student
- */
- public class Main2 {
- //
- public static void main(String[] args) {
- // instanceof (результат работы - значение типа boolean)
- String s = "HELLO JAVA";
- boolean isString = s instanceof String;
- System.out.println("isString=" + isString);
- //
- Person p = new Employee("Ivan", "Ivanov", "Google");
- //
- boolean isPerson = p instanceof Person;
- System.out.println("isPerson=" + isPerson);
- Employee e = new Employee("Ivan", "Ivanov", "Google");
- boolean isEmployee = e instanceof Employee;
- boolean isPerson1 = e instanceof Person;
- System.out.println("e.isEmployee=" + isEmployee);
- System.out.println("e.isPerson1=" + isPerson1);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement