Skip to content
Advertisement

Tag: reference

Implement inner-class-like reference behaviour? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post. Closed 6 months ago. Improve this question First of all, allow me to explain a “behaviour” that I observed, then I will ask in “Example” section. Inner-class-reference behaviour In Java we can

Where is the super reference in a Java instance method’s stack frame?

I read Bill Venner’s excellent Inside the Java Virtual Machine book, which, in Chapter 5 explores in detail, among other things, the composition of a JVM’s stack frame. (This chapter from the book also happens to be officially published here: https://www.artima.com/insidejvm/ed2/jvm8.html) Apart from this book I studied relatively much the runtime data areas of some JVM’s, especially their stack and

What is the difference between Address and Reference in Java?

First of all, I know that Java is call by value. However, in a certain article, there is no such thing as an address in Java, and you should use the word reference. In my opinion, both words are interpreted with the same meaning. Am I wrong? What is the difference between address and reference, and do you have such

Java Map for unique object instances?

A library I use contains a certain object type, LackingObject (some type), which lacks an attribute of type Ext (some type). If I was able to change the LackingObject class, I would simply add an attribute with type Ext, but LackingObject cannot be changed, nor extended. What I’d do now in languages like C or C++ is to create a

Reference counting Java

Consider the following java code: class Person { String name; int age; } Person p1 = new Person(); Person p2 = new Person(); Person p3 = p2; p3 = p1; How many total objects and reference …

Duplicating objects in Java

I learned that when you modify a variable in Java it doesn’t change the variable it was based on I assumed a similar thing for objects. Consider this class. After I tried this code I got confused. Please explain to me why changing any of the objects affects the other one. I understand that the value of variable text is

Can I pass parameters by reference in Java?

I’d like semantics similar to C#’s ref keyword. Answer Java is confusing because everything is passed by value. However for a parameter of reference type (i.e. not a parameter of primitive type) it is the reference itself which is passed by value, hence it appears to be pass-by-reference (and people often claim that it is). This is not the case,

Advertisement