
import java.lang.reflect.Array;
import java.util.NoSuchElementException;
import java.util.Objects;

public class SimpleLinkedList<T> {

    private static class Element<T> {

        final T value;
        Element next;

        Element(T value) {
            this.value = value;
        }
    }

    private Element<T> head;
    private int size;

    public SimpleLinkedList() {
    }

    public SimpleLinkedList(T[] values) {
        for (int ii = values.length - 1; ii >= 0; ii--) {
            push(values[ii]);
        }
    }

    public final void push(T value) {
        Element<T> newElement = new Element<>(value);
        this.size++;
        if (Objects.isNull(head)) {
            head = newElement;
        } else {
            newElement.next = head;
            head = newElement;
        }
    }

    public T pop() {
        if (Objects.isNull(head)) {
            throw new NoSuchElementException();
        }
        T value = head.value;
        head = head.next;
        this.size--;
        return value;
    }

    public void reverse() {
        Element<T> current = head;
        Element<T> next;
        Element<T> previous = null;
        while (Objects.nonNull(current)) {
            next = current.next;
            current.next = previous;
            previous = current;
            current = next;
        }
        head = previous;
    }

    public T[] asArray(Class<T> clazz) {
        T[] result = newArray(clazz, this.size);
        int index = 0;
        Element<T> current = head;
        while (Objects.nonNull(current)) {
            result[index++] = current.value;
            current = current.next;
        }
        return result;
    }

    private <T> T[] newArray(Class<T> clazz, int size) {
        @SuppressWarnings("unchecked")
        T[] arr = (T[]) Array.newInstance(clazz, size);

        return arr;
    }

    public int size() {
        return this.size;
    }
}

@@ -94,23 +94,16 @@
 jects;%0A%0A
-public 
 class Si
@@ -200,16 +200,19 @@
  Element
+%3CT%3E
  next;%0A%0A
@@ -339,31 +339,24 @@
  size;%0A%0A    
-public 
 SimpleLinked
@@ -375,23 +375,16 @@
  %7D%0A%0A    
-public 
 SimpleLi
@@ -424,17 +424,16 @@
 r (int i
-i
  = value
@@ -451,17 +451,15 @@
 1; i
-i
  %3E= 0; 
-i
 i--)
@@ -486,17 +486,16 @@
 values%5Bi
-i
 %5D);%0A    
@@ -510,23 +510,16 @@
   %7D%0A%0A   
- 
-public
  final v
@@ -785,23 +785,16 @@
  %7D%0A%0A    
-public 
 T pop() 
@@ -999,23 +999,16 @@
  %7D%0A%0A    
-public 
 void rev
@@ -1331,23 +1331,16 @@
  %7D%0A%0A    
-public 
 T%5B%5D asAr
@@ -1398,21 +1398,16 @@
 (clazz, 
-this.
 size);%0A 
@@ -1642,12 +1642,8 @@
 vate
- %3CT%3E
  T%5B%5D
@@ -1811,15 +1811,8 @@
     
-public 
 int 

simplify example implementation