简体   繁体   English

如何创建嵌套在Static类中的类的实例,而该类又嵌套在Non-Static类中?

[英]How to create an instance of a class nested within Static class which is in turn nested within Non-Static class?

How to create an instance of Node in following? 下面如何创建Node的实例?

public class RemoveDups_1{

    public static class LinkedList{

        static int i = 5;

        class Node{

        }
    }
}

I think that is a very strange way to work with objects, but if you are interested to create an instance of Node class you could achieve it in this way: 我认为这是使用对象的一种非常奇怪的方式,但是如果您有兴趣创建Node类的实例,则可以通过以下方式实现它:

RemoveDups_1.LinkedList linkedList = new RemoveDups_1.LinkedList();
RemoveDups_1.LinkedList.Node node = linkedList.new Node();

Source: Oracle documentation about nested classes 资料来源: 有关嵌套类的Oracle文档

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM