Advertisement
Guest User

Untitled

a guest
Mar 29th, 2015
240
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.11 KB | None | 0 0
  1. package com.javarush.test.level07.lesson06.task01;
  2.  
  3. /* 5 различных строчек в списке
  4. 1. Создай список строк.
  5. 2. Добавь в него 5 различных строчек.
  6. 3. Выведи его размер на экран.
  7. 4. Используя цикл выведи его содержимое на экран, каждое значение с новой строки.
  8. */
  9.  
  10. import java.io.BufferedReader;
  11. import java.io.InputStreamReader;
  12. import java.util.ArrayList;
  13.  
  14. public class Solution
  15. {
  16.     public static void main(String[] args) throws Exception
  17.     {
  18.         //Напишите тут ваш код
  19.         ArrayList<String> list = new ArrayList<String>();
  20.         BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
  21.         String n = reader.readLine();
  22.  
  23.         while (!n.isEmpty())
  24.         {
  25.           list.add(n);
  26.           n = reader.readLine();
  27.         }
  28.  
  29.     System.out.println(list.size());
  30.         for (int i = 0; i < list.size(); i++)
  31.         {
  32.             System.out.println(list.get(i));
  33.         }
  34.  
  35.  
  36.     }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement