开发者

Does Java make distinction between value type and reference type

C开发者_JAVA百科# makes distinction of those two. Does java do the same or differently?


In Java, all objects and enums are reference types, and all primitives are value types. The distinction between the two is the same as in C# with respect to copy semantics, but you cannot define a new value type in Java.


In Java, the primitives are value types, classes and arrays are reference types.


Actually, everything in Java is passed by value, references being a special type of value, just like pointers are values in C. More about the semantics here:

http://javadude.com/articles/passbyvalue.htm

C# on the other hand, does have real references a la C++, which are unrelated to reference values... Can it get any more confusing than that?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜