zoukankan      html  css  js  c++  java
  • Java

      熟悉一下Java。。。

    package ChianTable;
    
    import java.util.Scanner;
    
    /**
     * Created by Administrator on 2018/3/26.
     */
    public class LinkedList {
    
        private LinkedList prev;
        private LinkedList next;
        private int val;
    
        private LinkedList head;
        private LinkedList rear;
    
        public LinkedList() {
            super();
        }
    
        public LinkedList(LinkedList p, LinkedList n, int v) {
            super();
            this.prev = p;
            this.next = n;
            this.val = v;
        }
    
        public LinkedList Create() {
    
            Scanner type = new Scanner(System.in);
            int val = type.nextInt();
    
            LinkedList nextNode = new LinkedList(null, null, val);
            this.head = nextNode;
            while ((val = type.nextInt()) != 0) {
                LinkedList curr = new LinkedList(nextNode, null, val);
                nextNode.next = curr;
                nextNode = curr;
            }
            this.rear = nextNode;
            nextNode.next = null;
    
            return this.head;
        }
    
        public void nextprint() {
            if (this.head != null) {
                System.out.println(this.head.val);
                this.head = this.head.next;
                nextprint();
            }
        }
    
        public void prevprint() {
            if (this.rear != null) {
                System.out.println(this.rear.val);
                this.rear = this.rear.prev;
                prevprint();
            }
        }
    
    }

      测试:

    package main;
    
    
    import ChianTable.LinkedList;
    
    public class Main {
    
        public static void main(String [] args) {
    
            LinkedList linkedlist = new LinkedList();
    
            linkedlist.Create();
            linkedlist.nextprint();
            linkedlist.prevprint();
    
        }
    }
    

      

  • 相关阅读:
    Python:数据驱动测试DDT
    python-日志模块logging
    《测试架构师修炼之道》测试点
    Pycharm中使用Github
    MySql视图及存储过程
    MySQL游标和触发器
    MySQL事务处理及字符集和校对顺序
    MySQL安全管理、数据库维护及改善性能
    mysql-数据类型
    mysql-日期时间函数
  • 原文地址:https://www.cnblogs.com/darkchii/p/8653921.html
Copyright © 2011-2022 走看看