Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Collection
- {
- private static Scanner scanner = new Scanner(System.in);
- public static void main(String[] args)
- {
- collectionFiller(scanner, dimensionCounter(scanner));
- scanner.close();
- }
- public static int dimensionCounter(Scanner scanner)
- {
- //Введение размерности массива чисел
- System.out.print("Dimension: ");
- int dimension = scanner.nextInt();
- System.out.printf("Enter dimension: %d \n", dimension);
- return dimension;
- }
- public static void collectionFiller(Scanner scanner, int dimension)
- {
- int[] collection = new int[dimension];
- //Цикл ввода элементов массива
- for (int i = 0; i < dimension; i++)
- {
- System.out.print("Enter int "+ (i+1) +":");
- collection[i] = scanner.nextInt();
- System.out.printf("Char entered: %d \n", collection[i]);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement