Who is saying string s = new string ("xyz"); create two string object?

xiaoxiao2021-03-06  49

On the homepage of 9CBS, you see an article called a trap in the Java interview, where there is the following topic: ninth, string s = new string ("xyz"); create a few String Object? Two objects, One is "XYX", one is a reference object S with "XYX". Is it as follows, a string s = new string ("xyz") Is it necessary to create two objects? Can I refer to it? What is an object, a reference, a handle, can a pointer be called an object? Isn't it necessary to create two objects anything like integer integer = new integer (100)? This seems to be increasingly wrong, it should be the type of free memory in the stack to call the object! 0: New # 5; // Class String 3: DUP 4: LDC # 6; // String XYZ 6: InvokeSpecial # 7; // Method Java / Lang / String. "" :( ljava / lang / string ;) V 9: ASTORE_1 I don't know how to think about it? Kypfos@msn.com

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

New Post(0)