Created
February 22, 2016 19:29
-
-
Save Viacheslav77/1c61db084baf5db32d26 to your computer and use it in GitHub Desktop.
Написать метод, который создаст список, положит в него 10 элементов, затем удалит первые два и последний, а затем выведет результат на экран.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package ArrayToList; | |
| import java.util.ArrayList; | |
| /*Написать метод, который создаст список, положит в него 10 | |
| элементов, затем удалит первые два и последний, а затем выведет | |
| результат на экран.*/ | |
| import java.util.LinkedList; | |
| import java.util.List; | |
| public class MyClass { | |
| public static void main(String [] args){ | |
| String [] str = {"1","2","3","4","5","6","7","8","9","10"}; | |
| List <String> list = new ArrayList(); | |
| for(String s: str) | |
| list.add(s); | |
| list.remove(0); | |
| list.remove(0); | |
| list.remove(list.size()-1); | |
| for(String s: list) | |
| System.out.print(s); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment