Assume I have the following code.
class D { static Integer i1 = 42; }
Is it true that D has an Integer? Or is it only for instance variable that we can have a has-a relation?
I also wonder about very similar, if a primitive variable also can make a has-a relation or is it strictly for classes? e.g.
class D { int i1 = 42; }
It seems that D has an int but it is a primitive and I'm not sure that primitives are legal for a has-a relationship.
To construct an example that might be awkward, I assume that it is not a has-a relation that the String s1 = "s1"; has a char because it is not that kind of relation even though s and 1 are variables types of char in this case.
Similarly, I assume it's false that a class or an object "has" something that it only has conceptually or as internal implementation rather than the plain way of how we understand a has-a relation.
AFAIK, Java has no class Digit, it has no class Mantissa, it has no class Coefficient and no class Fraction when I browse the javadocs for Java 8, while Java has many classes for many different purposes. I suppose the reason for omitting certain classes that are fairly common concepts could be that the object would not be useful or that the class hierarchy would become unnecessary complex.
Did I understand the usage and definition of the has-a relation? Did I misunderstand something? Are there corner cases that I didn't think of?