- /* package whatever; // don't place package name! */ 
-   
- import java.util.*; 
- import java.lang.*; 
- import java.io.*; 
-   
- /* Name of the class has to be "Main" only if the class is public. */ 
- class Ideone 
- { 
- 	{ 
- 	    ListaDinamica<String> lista = new ListaDinamica<>(); 
- 	    lista.add(s1); 
- 	    lista.add(s2); 
- 	    lista.remove(1); 
- 	    lista.add(s2); 
- 	    for(int i=0;i<lista.size();i++){ 
- 	        System- . out- . println(- lista. get(- i ));
 
- 	    } 
-     } 
- } 
-   
- class ListaDinamica<T> {     
-     private class Celula<E>{ 
-         E item; 
-         Celula<E> prox; 
-     }  
-   
-     private Celula<T> primeiro; 
-     private Celula<T> ultimo; 
-     private int tamanho; 
-   
-     public ListaDinamica(){ 
-         this.primeiro = new Celula<>(); 
-         this.ultimo = this.primeiro; 
-         this.tamanho = 0; 
-     } 
-   
-     public ListaDinamica(ListaDinamica<T> objetos){ 
-         this(); 
-         for(int i=0;i<objetos.size();i++){ 
-             this.add(objetos.get(i)); 
-         } 
-     } 
-   
-     public ListaDinamica(List<T> objetos){ 
-         this(); 
-         for(int i=0;i<objetos.size();i++){ 
-             this.add(objetos.get(i)); 
-         } 
-     } 
-   
-     public boolean isEmpty(){ 
-         return size()==0; 
-     } 
-   
-     public void add(T objeto){ 
-         if(isEmpty()){ 
-             Celula<T> aux = new Celula<>(); 
-             aux.item = objeto; 
-             this.primeiro.prox = aux; 
-             this.ultimo = aux; 
-             this.tamanho++; 
-         } 
-         else{ 
-             this.ultimo.prox = new Celula<>(); 
-             this.ultimo = this.ultimo.prox; 
-             this.ultimo.item = objeto; 
-             this.ultimo.prox = null; 
-             this.tamanho++; 
-         } 
-     } 
-   
-     public void remove(int i){ 
-         if(isEmpty())return; 
-         if(i==0){ 
-             this.primeiro.prox = this.primeiro.prox.prox; 
-             this.tamanho--; 
-             this.ultimo = this.primeiro; 
-         } 
-         else{ 
-             Celula<T> aux = this.primeiro.prox; 
-             for(int j=0;j<i;j++){ 
-                 if(j==i-1){ 
-                     aux.prox = aux.prox.prox; 
-                     if ( i == this.tamanho - 1 ) 
-                         this.ultimo = aux; 
-                     this.tamanho--; 
-                 } 
-                 else{ 
-                     aux = aux.prox; 
-                 } 
-             } 
-         } 
-     } 
-   
-     public T get(int i){ 
-         if(isEmpty()) { 
-             System- . out- . println("LISTA VAZIA");
 
-             return null; 
-         } 
-         if(i>=size()){ 
-             System- . out- . println("INDEX INVALIDO");
 
-             return null; 
-         } 
-         Celula<T> aux = this.primeiro.prox; 
-         for(int j=0;j<i;j++){ 
-             aux = aux.prox; 
-         } 
-         return aux.item; 
-     } 
-   
-     public int size(){ 
-         return this.tamanho; 
-     } 
- }