Advertisement
sergAccount

Untitled

Jul 3rd, 2021
1,116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.16 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 com.mycompany.ex16;
  7.  
  8.  
  9. public class Main5 {    
  10.     //
  11.     public static void printArray(int[] arr){
  12.         for (int i = 0; i < arr.length; i++) {            
  13.             System.out.println("arr[i]=" + arr[i]);
  14.         }        
  15.     }    
  16.     //
  17.     public static void main(String[] args) {
  18.         // массив целых чисел
  19.         int[] array;
  20.         //
  21.         array = new int[10];
  22.         array = null; // null литерал (ссылка на пустоту)
  23.         String s = null;
  24.         // провекрка на null
  25.         if(array!=null){
  26.             System.out.println("array НЕ null!!!");
  27.         }else{
  28.             System.out.println("array ссылается на null!!!");
  29.         }
  30.         // выводим первый элемент массива array
  31.         if(array!=null){
  32.             System.out.println("array[0]=" + array[0]);
  33.         }    
  34.         //
  35.         //printArray(array);
  36.        
  37.     }    
  38. }
  39.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement