Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.company;
- import java.lang.reflect.Array;
- import java.util.*;
- public class Main {
- static class Humans {
- private Scanner sc;
- Humans(Scanner _sc) {
- sc = _sc;
- }
- ArrayList<String> data = new ArrayList<String>();
- void readNames(int count) {
- for (int i = 0; i < count; ++i) {
- String name = sc.nextLine();
- data.add(name);
- }
- }
- void printAllNames() {
- for (int i = 0; i < data.size(); ++i) {
- System.out.println(data.get(i));
- }
- }
- }
- static class Digits {
- private Scanner sc;
- Digits(Scanner _sc) {
- sc = _sc;
- }
- ArrayList<Integer> data = new ArrayList<Integer>();
- void readDigits(int count) {
- for (int i = 0; i < count; ++i) {
- Integer digit = sc.nextInt();
- data.add(digit);
- }
- }
- void printAllDigits() {
- for (int i = 0; i < data.size(); ++i) {
- System.out.println(data.get(i));
- }
- }
- }
- public static void main(String[] args) {
- Scanner sc = new Scanner(System.in);
- Humans h = new Humans(sc);
- Digits d = new Digits(sc);
- h.readNames(3);
- d.readDigits(5);
- h.printAllNames();
- d.printAllDigits();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement