Several String objects?

xiaoxiao2021-03-06  42

Author: zfive5 (zhaozidong) email: zfive5@yahoo.com.cn

New Year's Day, friends asked me that XXX operation generated a few String objects - it also often in the Java interview question, I at the time I used the Java anti-compilation tool against a Class code to let him see, it is true that everything is! (Note: The following is the code that I have rewritten afterwards)

Java:

Package ZF5;

PUBLIC CLASS ZF5 {

Public zf5 () {}

Public static void main (string args []) {zf5 zf51 = new zf5 (); string a = "zfive5"; string a1 = new string ("Hello Zfive5"); string a2 = a; long A3 = 5L; Long A4 = New long (1L);}}

BYTECODE:

Package ZF5;

PUBLIC CLASS ZF5 {

Public zf5 () {// 0 0: ALOAD_0 // 1 1: InvokeSpecial # 1 // 2 4: NOP // 3 5: return}

转载请注明原文地址:https://www.9cbs.com/read-73077.html

New Post(0)