Android 代码编写问题

// ignore some codes

final Looper me = myLooper();

if (me == null) {

 throw new RuntimeException("No Looper; Looper.prepare() wasn't called on this thread.");

}

final MessageQueue queue = me.mQueue;

// ignore some codes


看了些Android源码,看到很多这种情况,当他们想用一个变量时,不是直接去用,而是换一个临时变量并且用 final 修饰。这是为什么呢?会提高性能吗?

final Looper me = myLooper();

final MessageQueue queue = me.mQueue;

他们就是这么做的。

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容