Advertisement
sergAccount

Untitled

Jul 3rd, 2021
1,012
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.29 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.  *
  10.  * @author student
  11.  */
  12. public class Main4 {
  13.     /*    
  14. Задача 3 (дополнительно)
  15. Создать метод который заполняет массив элементов типа double определенным числом (параметр метода)
  16. У данного метода должно быть два параметра (массив типа double и значение типа double)
  17. Метод должен возвращать значение типа void.
  18. Проверить данный метод вызвать его в методе main
  19.     */
  20.     //
  21.     public static void fillArray(double[] source, double value){
  22.         // fori+tab        
  23.         for (int i = 0; i < source.length; i++) {
  24.              source[i] = value;            
  25.         }
  26.     }
  27.     //    
  28.     public static void main(String[] args) {
  29.         double[] arr = {1.1, 3.3};
  30.         fillArray(arr, 10);
  31.         for (int i = 0; i < arr.length; i++) {
  32.             System.out.println("arr[i]=" + arr[i]);            
  33.         }
  34.     }    
  35. }
  36.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement