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.ex16;
- /**
- *
- * @author student
- */
- public class Main9 {
- /*
- // метод зависит от массива элементов
- public static int minOfArray(int[] array){
- return 0;
- }
- */
- // метод с произвольным количеством параметров (VarArgs)
- public static int min(int ... values){
- //
- System.out.println("values.len=" + values.length);
- for (int i = 0; i < values.length; i++) {
- int value = values[i];
- System.out.println("value=" + value);
- }
- return 0;
- }
- //
- public static void main(String[] args) {
- //
- System.out.println("2 params");
- min(2, 4);
- System.out.println("3 params");
- min(2, 4, 3);
- System.out.println("4 params");
- min(2, 4, 3, 4);
- //
- int[] arr = {1, 2, 3};
- min(arr);
- min();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement