Java中的内部静态类 [英] Inner static class in Java

查看:145
本文介绍了Java中的内部静态类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用内部静态类有什么好处?我应该在哪里选择其他选项?

What is benefit of using an inner static class? Where should I prefer it over other options?

它的内存是如何分配的?

And how is its memory allocated?

推荐答案

如果内部类是静态的,则不需要外部类的实例来实例化它。

If the inner class is static, you don't need an instance of the outer class to instantiate it.

如果内部类是公共的,它基本上只是一种名称范围技术,用于突出显示类属于外部类的事实。

If the inner class is public, it's basically just a name-scoping technique for highlighting the fact that the class "belongs" to the outer class.

如果你将内部类设为私有,它可以'在该课程之外使用。

If you make the inner class private however, it can't be used outside of that class.

这篇关于Java中的内部静态类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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