Hello, I'm trying to to convert this UML diagram to java code directly, and below is my code which doesn't seem to compile anyways. I'm not very sure about how to place the optional multiplicities in, e.g. 0..* and 0..1. Thank you for your help.
public class Person{
private String name;
private Person mom;
private Person dad;
private ArrayList<Person> child;
private ArrayList<Person> friend;
private ArrayList<School> alumni;
private School current = new School();
public Person(String name, Person mom, Person dad, ArrayList<Person> child, ArrayList<Person> friend, ArrayList<School> alumi, School current){
name = this.name;
mom = this.mom;
dad = this.dad;
child = this.child;
friend = this.friend;
alumni = this.alumni;
current = this.current;
}
}
public class School{
private String name;
private ArrayList<Person> student;
public School(String name, ArrayList<Person> student){
name = this.name;
student = this.student;
}
}

There is no standardized way of converting UML to Java, but I can tell you what is correct and not correct based on the UML and Java semantics.
An association between classes C1 and C2 may be implemented by a property in class C1, or by a property in class C2 or by properties in both classes. If an association does not have an arrowhead, all three options are possible and it is not defined which of these three options is the best. If an association is an arrow pointing from C1 to C2, then the first option is the best, the second option is incorrect and the third option is allowed. I have checked your Java code and it complies to these rules.
If class C1 has a property P implementing an association between class C1 and class C2 and the association has a multiplicity of
0..1at the side of C2, then P should have type C2 and C1 should have a constructor that does not initialize P. Your Java code is incorrect, because you should not initialize Person.School.If the multiplicity is
*or0..*, then P should be some kind of collection of C2. Class C1 should have a constructor that either does not initialize P or that can initialize P with an empty collection. The latter is the case in your Java code.