类可以嵌套在类中多少次? [英] How many times can classes be nested within a class?

查看:115
本文介绍了类可以嵌套在类中多少次?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在其中一个在线Java测试中遇到过这些问题。选项是4,5,8和任意次。

I came across this questions on one of the online Java Tests. The options were 4,5,8 and any number of times.

我只使用了一个内部类,但从未尝试过多个内部类。我想知道是否有人知道答案。

I have only used one inner class, but have never tried multiple ones. I was wondering if anyone knows the answer.

推荐答案

我自己尝试过:答案是无数次。以下是我的测试类,我没有编译错误。

I tried on my own: The answer is any number of times. The following is my test class, I had no compilation errors.



public class Test {


    public Test ()
    {

    }
    public static void main (String args[])
    {
    new Test ();
    }

    class Test2
    {
        class Test3
        {
            class Test4
            {
                class Test5{
                    class Test6{
                        class Test7{
                            class Test8{
                                class Test9
                                {

                                }
                            }
                        }
                    }
                }
            }

        }

    }


}

这篇关于类可以嵌套在类中多少次?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆