美文网首页
Android 代码编写问题

Android 代码编写问题

作者: 温柔的猴子 | 来源:发表于2017-09-17 19:44 被阅读0次

    // 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;

    他们就是这么做的。

    相关文章

      网友评论

          本文标题:Android 代码编写问题

          本文链接:https://www.haomeiwen.com/subject/ieemsxtx.html