【数据结构】·【链表】·【JAVA版】
来源:互联网 发布:叮叮软件定位查询 编辑:程序博客网 时间:2024/06/05 04:55
和C++并没有差别不大,主要是指针改为了引用变量,其他的链式结构基本可以参照这个
至于树的话注意下递归就大致可以了
package com.sun.study.test;class Link{public int data;public Link next;public Link(int data) {this.data = data;}public void display(){System.out.println("数据为:"+data);}}class LinkList{private Link first;public LinkList(){first=null;}public boolean isEmpty(){return(first == null);}public void insert(int data){Link newLink = new Link(data);newLink.next = first;first = newLink;}public void delete(int data){Link current = first;Link del = null;for(;current!=null;current=current.next){if(current.next.data == data){del=current.next;current.next = del.next;break;}}}public void display(){Link current= first;for(;current != null;current = current.next)System.out.println(current.data);}}class LinkListApp{public static void main(String[] args){LinkList list = new LinkList();list.insert(88);list.insert(45);list.insert(85);list.insert(90);list.insert(8);list.insert(4);list.insert(5);list.insert(9);System.out.println(list.isEmpty());list.display();System.out.println("---------------");System.out.println(list.isEmpty());list.delete(90);list.display();}}
0 0
- 【数据结构】·【链表】·【JAVA版】
- 数据结构java版三 Java内置数据结构
- Java数据结构(一) ---链表
- java数据结构 链表
- 数据结构JAVA--链表
- 数据结构--链表(java)
- 【Java数据结构】链表
- Java数据结构----链表
- java--数据结构--链表
- Java 数据结构(链表)
- Java数据结构-链表
- 《java数据结构》--链表
- JAVA数据结构:链表
- java数据结构--链表
- java 数据结构-链表
- 数据结构Java版-树
- [数据结构JAVA版]集合
- 数据结构回顾版-java数据结构-数组
- mac cocoa笔记
- Eclipse/MyEclipse注释模板和格式化模板的使用
- eclipse调整utf8
- Info.plist Utility Error: “Info.plist couldn't be opened because there is no such file”
- Java 面试题
- 【数据结构】·【链表】·【JAVA版】
- 无题
- POJ2418 Hardwood Species(二叉搜索树+字典树+MAP)
- 分析JVM的性能利器-iotop和jstack
- leetcode-Add Digits
- HLG 1530 Pie(浮点二分)
- 开启我的博客之旅
- Java <!--随机数的产生 -->
- [LeetCode] Longest Increasing Subsequence