PROGRAMMING:Jmu-java-04 advanced object oriented-03-interface-user defined interface arrayintegerstack
Define the 'integerstack' interface, which is used to describe a common method of storing a stack of integer elements
```java
public Integer push(Integer item);
//If the item is null, it will return null without stack. If the stack is full, null is also returned. If the insertion is successful, the item is returned.
public Integer pop(); // If it is empty, null is returned. When leaving the stack, only the top pointer is moved, and the corresponding position is not set to null
public Integer peek(); // Get the top of stack element, if it is empty, return null
public boolean empty(); // If it is empty, return true
public int size(); // Returns the number of elements in the stack
```
Define the implementation class' arrayintegerstack 'of integerstack, which is implemented internally by array. When creating, you can specify the internal array size.
###Main method description
1. Enter n to create an arrayintegerstack object that can contain n elements
2. Input m values and put them on the stack. The result of stack entry is printed every time.
3. Output the top of stack element, whether the output is empty, and output size
4. Use arrays. Tostring() to output the values in the internal array.
5. Input x, and then output the stack x times, printing every time.
6. Output the top element of stack, whether the output is empty, and output size
7. Use arrays. Tostring() to output the values in the internal array.
###Thinking:
If the implementation class of integerstack interface uses ArrayList to store elements, how to implement it? What changes need to be made to the test code?
###Input sample
```in
five
three
1 2 3
two
```
###Output sample
```out
one
two
three
3,false,3
[1, 2, 3, null, null]
three
two
1,false,1
[1, 2, 3, null, null]
```
answer:If there is no answer, please comment
```java
public Integer push(Integer item);
//If the item is null, it will return null without stack. If the stack is full, null is also returned. If the insertion is successful, the item is returned.
public Integer pop(); // If it is empty, null is returned. When leaving the stack, only the top pointer is moved, and the corresponding position is not set to null
public Integer peek(); // Get the top of stack element, if it is empty, return null
public boolean empty(); // If it is empty, return true
public int size(); // Returns the number of elements in the stack
```
Define the implementation class' arrayintegerstack 'of integerstack, which is implemented internally by array. When creating, you can specify the internal array size.
###Main method description
1. Enter n to create an arrayintegerstack object that can contain n elements
2. Input m values and put them on the stack. The result of stack entry is printed every time.
3. Output the top of stack element, whether the output is empty, and output size
4. Use arrays. Tostring() to output the values in the internal array.
5. Input x, and then output the stack x times, printing every time.
6. Output the top element of stack, whether the output is empty, and output size
7. Use arrays. Tostring() to output the values in the internal array.
###Thinking:
If the implementation class of integerstack interface uses ArrayList to store elements, how to implement it? What changes need to be made to the test code?
###Input sample
```in
five
three
1 2 3
two
```
###Output sample
```out
one
two
three
3,false,3
[1, 2, 3, null, null]
three
two
1,false,1
[1, 2, 3, null, null]
```
answer:If there is no answer, please comment