Advertisement
sergAccount

Untitled

Dec 6th, 2020
859
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.89 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 app7;
  7.  
  8. /**
  9.  *
  10.  * @author Admin
  11.  */
  12. public class App7 {
  13.  
  14.     /**
  15.      * @param args the command line arguments
  16.      */
  17.     public static void main(String[] args) {
  18.         // TODO code application logic here
  19.         int[] arr = {1, 2, 3};
  20.         System.out.println("arr[0]=" + arr[0]);
  21.         System.out.println("arr[1]=" + arr[1]);
  22.         System.out.println("arr[2]=" + arr[2]);    
  23.        
  24.         // необходимо использовать св-во length
  25.         int i = 3;
  26.         if(i<arr.length){
  27.             // выход за пределы массива
  28.             System.out.println("arr[3]=" + arr[i]);
  29.         }
  30.         System.out.println("OK!!!");
  31.     }
  32. }
  33.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement