First, the recursive relationships must be association. There is no recursive inheritance relationship! Second, to code a recursive association, just treat the class as two, one on each of the association. Follow the same rules on cardinality and navigability for regular associations. Of course, you will create one class, rather than two. Here are a few examples.
// these are the components that contain the current object as a part
Example 2: one-way recursive relationship between Components: Component (assembly side *) ——> (ingredient side *) Component
class Component
{
// native attributes and operations of component
List ingredientCompoments;
//these are parts contained in the current component object
}
Example 3: one-way recursive relationship between Employees: Employee (manager side 0..1) ——> (subordinate side *) Employee
class Employee
{
// native attributes and operations of Employee
List subordinates;
//these are employees managed by the current employee object
}
Example 4: two-way recursive relationship between Employees: Employee (manager side 0..1) —-- (subordinate side *) Employee
class Employee
{
// native attributes and operations of Employee
List subordinates;
//these are employees managed by the current employee object
Employee manager;
//this is the manager of the current employee object
}
Example 5: In the assembly pattern, recursive relationships are often translated into the relationship between the representative class and one of its subclass. Here is an example, and the code to implement the diagram is attached below.

public class Product
{
// code
}
public class SelfMadeProdiuct : Product {
//code
}
public class Part : SelfMadeProduct
{
// code
}
public class SemiProduct : SelfMadeProduct
{
// code
List ingredients;
// parts or other semi-finished products that make up the current semi-priduct
}