logo

Crowdly

Dadas las siguientes clases: class ListaEnlazada {     Node<Integer> inic...

✅ The verified answer to this question is available below. Our community-reviewed solutions help you understand the material better.

Dadas las siguientes clases:

class ListaEnlazada {

 

  Node<Integer> inicio;

 

  public String toString () {

    String resultado = "[";

    Node<Integer> aux = inicio;

    while (aux != null) {

      if (aux.next == null)

        resultado += aux.element;

      else

        resultado += aux.element + ", ";

      aux = aux.next;

    }

    return resultado + "]";

  }

}

class ListaEnlazadaJugar {

  static void prueba1 () {

    Node<Integer> nodo1 = new Node<Integer>(1, null);

    Node<Integer> nodo2 = new Node<Integer>(2, null);

    Node<Integer> nodo3 = new Node<Integer>(3, null);

    ListaEnlazada lista = new ListaEnlazada();

    nodo3.next = nodo2;   

    lista.inicio = nodo3;

    nodo2.next = nodo1;

    Node<Integer> nodo = lista.inicio;

    System.out.println("lista = " + lista);      

  }

  public static void main (String[] args) {

    prueba1();

  }

}

Indica lo que se imprime en el output:

More questions like this

Want instant access to all verified answers on moodle.upm.es?

Get Unlimited Answers To Exam Questions - Install Crowdly Extension Now!