java in the inner_Java Inner Classes

When thinking about inner classes in java, the first thing that comes to my mind is that, WHY do we need to add inner classes to normal one? Leave alone all the specific details of the Java syntax, I think the reason is quite SIMPLE: we are human beings and we are always looking for approaches with LESS effort to get things done. In a word, we are lazy and sometimes laziness can boost our technology to an unprecedented extend.

Access Control

Inner classes in Java have special access privileges from the scope in which they are defined. They can access all the fields of the outer class including date that would otherwise be private. So when it comes to the situation in which ONE class need to access some private data in another class and the private data are ONLY visible to this class, we'd better use inner class. Instead, we will need to define an access method of the outer class for the use of only one class. It is not worthwhile.

Then the question comes to HOW could the inner classes access fields of the outer class.

It's important to know that, the access control behavior is done by the compiler, not the virtual machine. In the virtual machine's perspective, the inner class and the outer one are two distinctive classes. With compilation, the inner class holds the reference of the outer one and the outer class adds special access methods implicitly. In the default constructor of the inner class, the reference of the outer class is passed to a filed added by the compiler in this way the inner class could know which instance it is bounded. Also, we can write the inner object constructor more explicitly, using the syntax:

outerObject.new InnerClass(construction parameters);

Local Inner Classes

The important thing that distinguishes local inner classes to normal ones is that, local inner classes are defined in the scope of a function. And local classes are never declared with access specifier (public/private) because they do not need one. They are only used in the scope of the function in which they are defined and they are totally hidden from the outer world, they are not visible even to other functions in the outer class.

There is another advantage of Java inner class: they can even access local variables which are defined final. The fact why the local variable should be defined final is that, the class gets the value in construction and if the value changed, it may cause some kind of conflicts.  If you really need to change the var value in the inner class, you can define the local var to be an array which means the reference to which can never be changed while the value it holds can be modified.

Anonymous Inner Classes

If we only need one instance of a class, we can use anonymous class which we do not need to specify a name for it. In Swing, we often create a new object of a class that implements the ActionListener interface.

Static Inner Classes

If we do not need the inner class hold the reference of the instance of the outer class, we use static classes. Only inner classes can be defined static.

Reference:

1. Core Java Vol 1. 8th edition. Page:258-295.

城市运行管理的重要性与挑战 城市运行体系是以人为本的服务和经济发展体系,涉及决策、管理和执行三个层次。当前城市运行管理面临城市化快速发展、资源环境制约和社会矛盾突出等挑战。信息技术的发展为城市运行管理提供了重要手段,城市信息化经历了数字化、智能化到智慧化的发展过程。我国城市信息化虽取得进展,但仍处于初级阶段,存在缺乏整体规划、资源浪费和协作效率不高等问题。 智慧城市综合运行管理解决方案 智慧城市运行管理中心(SCOC)是支撑城市运行综合管理的神经中枢,旨在掌控城市运行综合体征,促进服务型政府转型。该中心通过全面整合运行资源,服务城市未来发展,提升城市运行水平和突发事件处置效率。中心纵向提升综合职能,横向贯通专业分工,包括综合管理平台、专业管理平台和业务操作平台,覆盖城市交通、公共安全、生态环境等多个领域。 智慧城市综合运行管理平台的结构与功能 智慧城市综合运行管理平台包括决策支持系统、处置系统、基础设施和监测系统。平台通过综合展现系统、综合应急指挥系统、综合运行业务联动系统等,实现城市运行的综合监测和管理。物联网数据采集系统利用网络通讯技术,实现城市物联网设备的高效运行。平台还包含云计算业务支撑系统、城市基础数据库、视频图像云平台等,以支持城市运行管理的各个方面。 智慧城市综合运行管理解决方案的优势 该解决方案具有三个核心优势:首先,它提供了完整的智慧城市视角,不仅仅是指挥中心或数据中心,而是智慧城市的实际载体。其次,它建立了完整的城市运行联动体系,打通业务部门壁垒,形成有机融合的业务联动平台,提升业务处理效率和服务水平。最后,方案凝聚了多年智慧城市建设咨询经验,为城市运行管理提供了成熟的解决方案。 项目实施建议 智慧城市运行管理中心的建设思路和项目实施建议是方案的重要组成部分,旨在指导城市如何有效实施智慧城市运行管理解决方案,以应对城市运行管理的挑战,提升城市管理的智能化和效率。通过这些建议,城市能够更好地规划和实施智慧城市项目,实现可持续发展。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值