2024年Java最新Java数据结构-链表(LinkedList)(四),京东面试真题解析

最后

针对以上面试题,小编已经把面试题+答案整理好了

最新大厂必问微服务面试题汇总:SpringCloud、Boot、Dubbo

最新大厂必问微服务面试题汇总:SpringCloud、Boot、Dubbo

最新大厂必问微服务面试题汇总:SpringCloud、Boot、Dubbo

面试专题

image

除了以上面试题+答案,小编同时还整理了微服务相关的实战文档也可以分享给大家学习

image

image

image

本文已被CODING开源项目:【一线大厂Java面试题解析+核心总结学习笔记+最新讲解视频+实战项目源码】收录

需要这份系统化的资料的朋友,可以点击这里获取

  • 链接域next用来存放下一个节点的位置 ;

  • 变量p指向链表的头节点(首节点)的位置,从p出发能找到表中的任意节点。

代码实现《单向链表》

package com.daley.linkedlist;

import java.util.Iterator;

class Test{

public static void main(String[] args) {

MyLinkedList ml = new MyLinkedList<>();

ml.insert(“aa”);

ml.insert(“bb”);

ml.insert(“cc”);

ml.insert(0,“dd”);

for (Object s : ml){

System.out.println(s);

}

}

}

public class MyLinkedList implements Iterable {

//记录头结点

private Node head;

//记录链表的长度

private int N;

public MyLinkedList(){

this.head = new Node(null,null);

this.N = 0;

}

/**

  • 定义节点类

*/

private class Node{

T item ; //存储数据

Node next; //下一个节点

public Node(T item, Node next) {

this.item = item;

this.next = next;

}

}

/**

  • 清空链表

*/

public void clear(){

this.head = null;

this.N = 0;

}

/**

  • 判断链表是否为空,是返回true,否返回false

  • @return

*/

public boolean isEmpty(){

return this.N == 0;

}

/**

  • 获取链表中元素的个数

  • @return

*/

public int length(){

return this.N;

}

/**

  • 读取并返回链中的第in

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值