一、满足以下三个条件,一个final变量就不再是一个变量,而是一个直接量。

  1. 使用final修饰符修饰。
  2. 在申明的时候就进行初始化
  3. 初始化的值在编译器就可以确定。

二、在什么情况下初始化的值在编译期是可以确定下来的?

  被赋的表达式只是基本的算术表达式或字符串链接运算,没有访问普通变量,调用方法。  

package fianlFieldCase;

public class Test {

    public static void main(String[] args) {

        final String str1 = "final" + "field";
final String str2 = "java" + 8; //下面的str3的值因为调用了方法,所以值在编译期不能确定
final String str3 = "java" + String.valueOf(8);
final int a = 2 + 3;
final double b = 1.5 / 3;
System.out.println("java8" == str2);
System.out.println("java8" == str3);
}
}

  编译以后的class文件如下:

aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAa4AAAE0CAIAAAD7akDoAAAcQklEQVR4nO2drZbjOrNA9TwDL9RzTMh5AD1Bk5Cv6QcVENjrPEBAM9E+TcNPE4MZMuQ2vrgusC2VZNlx/tydZO81a03aKVvKj3dKll02IvLf//5XAAAeGCOoEAAeHlQIAIAKAQAuqMIPt3o2q63/c/6mZtF4azqsb9RCF07aXnDtxvTq/TKTWjqqodo2i2fjU7Et671LrwgAFuGSWeGHW06FjbcnOm+ScqtZM8FFFZ6zzcpTwUUpNt5quQPAIiQVbs3q2Ww+mtetWT2b1a7bff+829Wzaf9tPtKK+52Jy5/eG5FWhfapXdg7sb76p+/Cdv51G58Kmz4ytl4nJYQqU6umYCl37MNa1VhbJpT9lqsqzCR4oKGD24z5nwvdU6GeBg47ny911mp/VlpvlyNWgIOorLB53ZqnrXv97B6XPvr0T89uLyKtB3vZ7XdKhZ3L7OvnoKW0etg8Z6tED3YLs8cjjGWFA++EKItohJSDBVcMXisqHMpoGNl4q8fOeXAZ2TcZB8ijGW698/3D+DLGW0eFADMpVRgF9OFWrbliBvdsVsllNdl9uNXW799d9tRw9Wwc3bxuzeZDa7T/Nz3WnqlClS6Zik0GY945WeEwssnS1FI+RaRqoDPx2Gupdl4fwGzXmm4dAOZQqDAfw7q9hE0c2GZp3Yg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FQIAyJkzyGfcrQgA4BtBVggAgAoBAFAhAIBwijUAgHDhHQCAoEIAAMlU+Pv38J8x5os7CABwfVAhAAAqBABAhQAAMlDh32KM/OcdFQLAQzHICt//I+YvVAgADwUqBABAhQAAqBAAQGozyO/yPybaEBUCwCNAVggAgAoBAFAhAIDUT7H+629UCAAPBRfeAQCgQgAASrcCAAgqBAAQVAgAIKgQAEBQIQCAoEIAAEGFAACCCgEABBUCAAgqBAAQVAgAIKgQAEBQIQCAoEIAAEGFAACCCgEABBUCAAgqBAAQVAgAIKgQAEBE/h/1I57jJ/TqvgAAAABJRU5ErkJggg==" alt="" />

  从编译以后的结果可以看出,除了str3,其他变量的值在编译期间就可以确定下来的。由于str2是一个直接量,它直接被替换成"java8",str2便指向字符串常量池中的"java8",所以当"java8"和str2进行==比较的时候直接返回true。但是str3的值要在运行期才能确定,这样就不能指向常量池中的”java8“。

  常量池是专门用于管理在编译期被确定并被保存在已编译的class文件中的一些数据。它包括了关于类、方法、接口中的常量,还包括字符串常量。

  例如执行String a = "java",就会在字符串常量区缓存一个"java";当再执行String b = "java",b就直接指向刚刚缓存的"java"。所以a==b 返回true。

  

【JAVA】在编译期可直接替换的final变量的更多相关文章

  1. java在编译期和运行期都做了什么

    Java对象内存存储,引用传递,值传递详细图解 java对象在内存中的分配 编译过程: 编译器把一种语言规范转化为另一种语言规范的这个过程需要哪些步骤?回答这个问题需要参照<编译原理>,总 ...

  2. 深入分析Java的编译期与运行期

    不知大家有没有思考过,当我们使用IDE写了一个Demo类,并执行main函数打印 hello world时都经历了哪些流程么? 想通过这篇文章来分析分析Java的执行流程,或者换句话说想聊聊Java的 ...

  3. 深入了解JVM虚拟机8:Java的编译期优化与运行期优化

    java编译期优化 java语言的编译期其实是一段不确定的操作过程,因为它可以分为三类编译过程:1.前端编译:把.java文件转变为.class文件2.后端编译:把字节码转变为机器码3.静态提前编译: ...

  4. java - day014 - 编译期,运行期

    编译期 静态成员 私有变量 成员变量 运行期 非静态方法 package day1401; public class Test1 { public static void main(String[] ...

  5. JavaSe: String的编译期优化

    Java的编译期优化 因为工作的原因,经常会在没有源码的情况下,对一些产品的代码进行阅读.有时在解决Bug时,在运行环境下会直接去看class文件的字节码,来确定运行中版本是否正确的. 在看字节码时, ...

  6. java编译期优化

    java语言的编译期其实是一段不确定的操作过程,因为它可以分为三类编译过程: 1.前端编译:把.java文件转变为.class文件 2.后端编译:把字节码转变为机器码 3.静态提前编译:直接把*.ja ...

  7. java编译期优化与执行期优化技术浅析

    java语言的"编译期"是一段不确定的过程.由于它可能指的是前端编译器把java文件转变成class字节码文件的过程,也可能指的是虚拟机后端执行期间编译器(JIT)把字节码转变成机 ...

  8. 深入理解Java虚拟机读书笔记6----早期(编译期)优化

    六 早期(编译期)优化   1 “编译期”的含义     · 可能是指一个前端编译器把*.java文件转变成*.class文件的过程,前端编译器如:Sun的Javac.Eclipse JDT中的增量式 ...

  9. 【深入理解JAVA虚拟机】第4部分.程序编译与代码优化.1.编译期优化。这章编译和实战部分没理解通,以后再看。

    1.概述 1.1.编译器的分类 前端编译器:Sun的Javac. Eclipse JDT中的增量式编译器(ECJ)[1].  把*.java文件转变成*.class文件 JIT编译器:HotSpot ...

随机推荐

  1. RecyclerView设置verticalSapcing等

    RecyclerView没有像GridView那样有提供verticalSpacing属性,上StackOverflow找到了一种替代方法,代码如下 public class SpacesItemDe ...

  2. angular中的promise

    angular中的promise用法 标签(空格分隔): angular 前言 Promise其实是一个规范,用类似then().then()这样的链式调用形式来处理因为异步带来意大利面条式的代码(多 ...

  3. 用intent打开各种类型文件

    public class MyIntent { //android获取一个用于打开HTML文件的intent public static Intent getHtmlFileIntent( Strin ...

  4. POJ 1703 Find them, catch them (并查集)

    题目:Find them,Catch them 刚开始以为是最基本的并查集,无限超时. 这个特殊之处,就是可能有多个集合. 比如输入D 1 2  D 3 4 D 5 6...这就至少有3个集合了.并且 ...

  5. C++ 构造和析构

    1.继承关系可认为,子类在父类的基础上进行.从这个角度讲,可把它认为穿衣脱衣的过程.穿衣是:先穿内衣,再穿外套.脱衣是:先脱外套,在脱内衣.构造是:先调用父类构造方法,再调用子类构造方法.析构是:先调 ...

  6. 0703-APP-Notification-statue-bar

    1.展示显示textTicker和仅仅有icon的两种情况:当參数showTicker为true时显示否则不显示 // In this sample, we'll use the same text ...

  7. 新闻客户端nices

    https://github.com/android-cjj/nices

  8. [React] Higher Order Components (replaces Mixins)

    Higher order components will allow you to apply behaviors to multiple React components. So the idea ...

  9. python抓取伯乐在线的全部文章,对标题分词后存入mongodb中

    依赖包: 1.pymongo 2.jieba # -*- coding: utf-8 -*- """ @author: jiangfuqiang "" ...

  10. 优化 MySQL 中的分页

    英文:Robert Eisele 译者:Giraffe 链接:http://yemengying.com/2016/05/28/optimized-pagiantion-mysql/ 一道面试的问题, ...