PROGRAMMING:Jmu-java-02 basic syntax - 08 introduction to ArrayList
This exercise is mainly used to practice how to use ArrayList to replace arrays.
Create a new 'ArrayList < string > strlist' to store strings, and then perform the following operations.
**Prompt: * query ArrayList in JDK document.
**Note: * Please use ` system. Out. Println (strlist)'To output list elements.
###Input format
1 * * enter * * n strings and put them in 'strlist'. Until the input is'!! end!!` End the input.
2. Add a 'begin' at the head and an 'end' at the tail of the 'strlist'.
3. Output list elements
4 * * input: * * string ` str`
5. Judge whether the 'strlist' contains the string 'STR'. If it contains the output 'true', otherwise it outputs' false '. And the output subscript does not contain the return - 1.
6. Look from the back to the front in the strlist. Return its subscript, return - 1 if not found.
7. Remove the first (subscript 0) element and output. Then output the list elements.
8 * * input: * * string str
9. Set the second (subscript 1) element to the string str
10. Output list elements
11 * * input: * * string str
12. Traverse the strlist, put the element containing STR in the string into another 'ArrayList strlist1', and then output strlist1.
13. Use the 'Remove' method in strlist to remove the first element equal to str.
14. Output strlist list elements.
15. Use the 'clear' method to clear the strlist. Then output the contents of the strlist, ` size() 'and ` isempty()', which are connected by ','.
###Input example:
```in
a1 b1 3b a2 b2 12b c d !! end!!
b1
second
b
```
###Output example:
```out
[begin, a1, b1, 3b, a2, b2, 12b, c, d, end]
true
two
two
begin
[a1, b1, 3b, a2, b2, 12b, c, d, end]
[a1, second, 3b, a2, b2, 12b, c, d, end]
[3b, b2, 12b]
[a1, second, 3b, a2, b2, 12b, c, d, end]
[],0,true
```
answer:If there is no answer, please comment
Create a new 'ArrayList < string > strlist' to store strings, and then perform the following operations.
**Prompt: * query ArrayList in JDK document.
**Note: * Please use ` system. Out. Println (strlist)'To output list elements.
###Input format
1 * * enter * * n strings and put them in 'strlist'. Until the input is'!! end!!` End the input.
2. Add a 'begin' at the head and an 'end' at the tail of the 'strlist'.
3. Output list elements
4 * * input: * * string ` str`
5. Judge whether the 'strlist' contains the string 'STR'. If it contains the output 'true', otherwise it outputs' false '. And the output subscript does not contain the return - 1.
6. Look from the back to the front in the strlist. Return its subscript, return - 1 if not found.
7. Remove the first (subscript 0) element and output. Then output the list elements.
8 * * input: * * string str
9. Set the second (subscript 1) element to the string str
10. Output list elements
11 * * input: * * string str
12. Traverse the strlist, put the element containing STR in the string into another 'ArrayList strlist1', and then output strlist1.
13. Use the 'Remove' method in strlist to remove the first element equal to str.
14. Output strlist list elements.
15. Use the 'clear' method to clear the strlist. Then output the contents of the strlist, ` size() 'and ` isempty()', which are connected by ','.
###Input example:
```in
a1 b1 3b a2 b2 12b c d !! end!!
b1
second
b
```
###Output example:
```out
[begin, a1, b1, 3b, a2, b2, 12b, c, d, end]
true
two
two
begin
[a1, b1, 3b, a2, b2, 12b, c, d, end]
[a1, second, 3b, a2, b2, 12b, c, d, end]
[3b, b2, 12b]
[a1, second, 3b, a2, b2, 12b, c, d, end]
[],0,true
```
answer:If there is no answer, please comment