Java - make class required for other class : <p>i have 2 class, planet and moon, my plan is to make moon class require planet class, so first i create planet and then create moon, how to do it?
my planet class :</p>

<pre><code>public class planet {
    //planet name
    private String namaPlanet;
    //total moon per planet
    private int jmlBulan;
    //revolution and rotation
    private double jmlRotasi, jmlRevolusi;
public planet(String namaPlanet, int jmlBulan, double jmlJamPhari, double jmlHariPtahun) {
    this.namaPlanet = namaPlanet;
    this.jmlBulan = jmlBulan;
    this.jmlRotasi = jmlJamPhari;
    this.jmlRevolusi = jmlHariPtahun;
}

public planet(String namaPlanet, double jmlRotasi, double jmlRevolusi) {
    this.namaPlanet = namaPlanet;
    this.jmlRotasi = jmlRotasi;
    this.jmlRevolusi = jmlRevolusi;
}
}
</code></pre>

<p>moon class :</p>

<pre><code>public class bulan extends planet {
private String namaBulan;
public bulan(String namaBulan, String namaPlanet,double jmlJamPhari, double jmlHariPtahun) {
    super(namaPlanet, jmlJamPhari, jmlHariPtahun);
    this.namaBulan = namaBulan;
}
}
</code></pre>
