Advertisement
sergAccount

Untitled

Jun 26th, 2021
1,100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.03 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.ex15;
  7.  
  8. public class Main2 {
  9.     // определим метод в качестве параметра метода передадим массив целых чисел
  10.     // printArray - имя метода
  11.     // arr - параметр типа массив
  12.     public static void printArray(int[] arr){
  13.         // fori
  14.         for (int i = 0; i < arr.length; i++) {
  15.              System.out.println("arr[" + i + "]=" + arr[i]);            
  16.         }
  17.     }    
  18.     // резултат работы метода - массив элементов
  19.     public static int[] createEmptyArray(){
  20.         return new int[10];
  21.     }    
  22.     //
  23.     public static void main(String[] args) {
  24.         int[] array = {10, 2, 33, 6, 777};
  25.         printArray(array);
  26.        
  27.         int[] result = createEmptyArray();
  28.     }    
  29. }
  30.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement