本文介绍了如何在链表中获取节点组件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

学习如何reverse-a-linked-列表.该链接非常具有描述性和清晰性.但不知何故,我不知道如何获取需要传递给下面方法的 Node 组件.我在 LinkedList 下没有找到任何方法获取节点.抱歉问了一个愚蠢的问题,但网上到处都是,假设我们有 Node 组件,然后程序从那里开始

Learnt how to reverse-a-linked-list. The link is very descriptive and clear. But somehow I'm not getting how to get the Node component which needs to be passed to below method. I did not find any method under LinkedListto get the Node.Sorry for asking dumb question but everywhere on net, it's assumed we have the Node component, and then program starts from there

public void recursiveReverse(Node currentNode ){
    ...
}

推荐答案

您必须从头开始编写自己的 LinkedList 类来实现该方法.java.util.LinkedList 不公开其内部实现.例如,节点被称为条目,而该类 java.util.LinkedList.Entry 是私有的.

You'll have to write your own LinkedList class from scratch to implement that method. java.util.LinkedList doesn't expose its internal implementation. For example, the nodes are called entries instead, and that class, java.util.LinkedList.Entry, is private.

这篇关于如何在链表中获取节点组件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-29 23:46