第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定

運行代碼無效果

為什么代碼提交沒錯,但是運行點擊按鈕沒有效果??

正在回答

2 回答

public class MyLinkedList<E> extends AbstractList<E>{
?? ?private Node<E> head, tail;
?? ?private int size = 0;
?? ?public MyLinkedList() {
?? ??? ?
?? ?}
?? ?
?? ?public E getFirst() {
?? ??? ?if (size == 0) {
?? ??? ??? ?return null;
?? ??? ?}
?? ??? ?else {
?? ??? ??? ?return head.element;
?? ??? ?}
?? ?}

?? ?public E getLast() {
?? ??? ?if (size == 0) {
?? ??? ??? ?return null;
?? ??? ?}
?? ??? ?else {
?? ??? ??? ?return tail.element;
?? ??? ?}
?? ?}
?? ?
?? ?public void addFirst(E e) {
?? ??? ?Node<E> newNode = new Node<E>(e); // Create a new Node
?? ??? ?newNode.next = head;// link the new node with the head
?? ??? ?head = newNode; // head points to the new node
?? ??? ?size++;
?? ??? ?
?? ??? ?if (tail == null) // the new node is the only node in list
?? ??? ??? ?tail = head;
?? ?}
?? ?
?? ?public void addLast(E e) {
?? ??? ?Node<E> newNode = new Node<E>(e); // Create a new Node for e
?? ??? ?
?? ??? ?if (tail == null) {
?? ??? ??? ?head = tail = newNode; // The only node in list
?? ??? ?}
?? ??? ?else {
?? ??? ??? ?tail.next = newNode; // link the new with the last node
?? ??? ??? ?tail = tail.next; // tail now points to the last node
?? ??? ?}
?? ??? ?
?? ??? ?size++; // Increase size
?? ?}
?? ?
?? ?public void add(int index, E e) {
?? ??? ?if (index == 0) addFirst(e);// Insert first
?? ??? ?else if (index >= size) addLast(e); //Insert last
?? ??? ?else { // Insert in the middle
?? ??? ??? ?Node<E> current = head;
?? ??? ??? ?for (int i = 1; i < index; i++)
?? ??? ??? ??? ?current = current.next;
?? ??? ??? ?Node<E> temp = current.next;
?? ??? ??? ?current.next = new Node<E>(e);
?? ??? ??? ?(current.next).next = temp;
?? ??? ??? ?size++;
?? ??? ?}
?? ?}
?? ?
?? ?public E removeFirst() {
?? ??? ?if (size == 0)
?? ??? ??? ?return null;
?? ??? ?else if (size == 1)
?? ??? ?{
?? ??? ??? ?Node<E> temp = head;
?? ??? ??? ?head = tail = null;
?? ??? ??? ?size? = 0;
?? ??? ??? ?return temp.element;
?? ??? ?}
?? ??? ?else
?? ??? ?{
?? ??? ??? ?Node<E> temp = head;?? ?
?? ??? ??? ?head = head.next;
?? ??? ??? ?size--;
?? ??? ??? ?return temp.element;
?? ??? ?}?? ?
?? ?}
?? ?
?? ?public E removeLast() {
?? ??? ?if (size == 0)
?? ??? ??? ?return null; // Nothing to remove
?? ??? ?else if (size == 1) // only one element in the list
?? ??? ?{
?? ??? ??? ?Node<E> temp = head;
?? ??? ??? ?head = tail = null; // list becomes empty
?? ??? ??? ?size = 0;
?? ??? ??? ?return temp.element;
?? ??? ?}
?? ??? ?else
?? ??? ?{
?? ??? ??? ?Node<E> current = head;
?? ??? ??? ?
?? ??? ??? ?for (int j = 0; j < size - 2; j++)
?? ??? ??? ??? ?current = current.next;
?? ??? ??? ?
?? ??? ??? ?Node<E> temp = tail;
?? ??? ??? ?tail = current;
?? ??? ??? ?tail.next = null;
?? ??? ??? ?size--;
?? ??? ??? ?return temp.element;
?? ??? ?}
?? ?}
?? ?
?? ?public E remove(int index) {
?? ??? ?if (index < 0 || index >= size)
?? ??? ??? ?return null; //Out of range
?? ??? ?else if (index == 0)
?? ??? ??? ?return removeFirst(); // Remove first
?? ??? ?else if (index == size - 1)
?? ??? ??? ?return removeLast(); // Remove last
?? ??? ?else {
?? ??? ??? ?Node<E> previous = head;?? ?
?? ??? ??? ?for (int i = 1; i <index; i++) {
?? ??? ??? ??? ?previous = previous.next;
?? ??? ??? ?}
?? ??? ??? ?
?? ??? ??? ?Node<E> current = previous.next;
?? ??? ??? ?previous.next = current.next;
?? ??? ??? ?size--;
?? ??? ??? ?return current.element;
?? ??? ?}
?? ?}
?? ?
?? ?public String toString() {
?? ??? ?StringBuilder result = new StringBuilder("[");
?? ??? ?
?? ??? ?Node<E> current = head;
?? ??? ?for (int i = 0; i < size; i++) {
?? ??? ??? ?result.append(current.element);
?? ??? ??? ?current = current.next;
?? ??? ??? ?if (current != null) {
?? ??? ??? ??? ?result.append(", ");
?? ??? ??? ?}
?? ??? ??? ?else {
?? ??? ??? ??? ?result.append("]");
?? ??? ??? ?}
?? ??? ?}
?? ??? ?
?? ??? ?return result.toString();
?? ?}
?? ?
?? ?public void clear() {
?? ??? ?head = tail = null;
?? ?}
?? ?
?? ?public boolean contains(Object o) {
?? ??? ?System.out.println("Implementation left as an exercise");
?? ??? ?return true;
?? ?}
?? ?
?? ?public E get(int index) {
?? ??? ?System.out.println("Implementation left as an exercise");
?? ??? ?return null;
?? ?}
?? ?
?? ?public int indexOf(Object o) {
?? ??? ?System.out.println("Implementation left as an exercise");
?? ??? ?return 0;
?? ?}
?? ?
?? ?public int lastIndexOf(Object o) {
?? ??? ?System.out.println("Implementation left as an exercise");
?? ??? ?return 0;
?? ?}
?? ?
?? ?public E set(int index, E e) {
?? ??? ?System.out.println("Implementation left as an exercise");
?? ??? ?return null;
?? ?}
?? ?
?? ?private static class Node<E> {
?? ??? ?E element;
?? ??? ?Node<E> next;
?? ??? ?
?? ??? ?public Node(E element) {
?? ??? ??? ?this.element = element;
?? ??? ?}
?? ?}

?? ?@Override
?? ?public int size() {
?? ??? ?// TODO Auto-generated method stub
?? ??? ?return 0;
?? ?}
}

0 回復(fù) 有任何疑惑可以回復(fù)我~

你代碼怎么寫的?

0 回復(fù) 有任何疑惑可以回復(fù)我~

舉報

0/150
提交
取消
JavaScript入門篇
  • 參與學(xué)習(xí)       741083    人
  • 解答問題       9811    個

JavaScript做為一名Web工程師的必備技術(shù),本教程讓您快速入門

進入課程

運行代碼無效果

我要回答 關(guān)注問題
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號