I understand code fully however I’m having a bit of trouble understanding UML as it relates to code.
Question 1 – If I have a class
public class one
{....}
public class two
{
one ob;
public two(){ob=new one();}
}
I know this is an association but do I show this in a class diagram with an arrow or not?

Question 2 – if I have the following class
public class three
{
public three(){.........}
public void method() { one obt=new one(); }
}
Is this an association between class three and class one? I’m not sure since its being applied from the method.
If class
onehas no reference to classtwothen you should have an arrow head. But it points fromtwotoone(opposite way to how you have it shown). Reason: the arrow indicates navigability. Classtwocan navigate to classonebecause it holds an instance. The opposite is not true. Technically it should be an open arrowhead, not the closed form you’ve used.If the only reference from
threetooneis as a method parameter then you’d most likely show as a dependency not an association. Associations declare a systematic relationship among the entities – like aPurchase Orderconsisting ofOrder Lines. In code that most often translates to a member variable (or collection thereof). Dependencies are a weaker form of relationship than Associations and don’t imply a systematic link.hth.