This is my first time doing java codes, and I am confused on this. I supposed to compile 2 files, the first is Lingkaran.java
which contains class lingkaran
, and the second is MLingkaran.java
which is the main file
. The Lingkaran.java
compiles just fine, but when I tried to compile the MLingkaran.java
, these errors came out.
C:\Users\LENOVO PC>javac F:\SchoolSums-Praktikum\Semester4\PemrogramanBerbasisObjek\14.03.17\2\MLingkaran.java F:\SchoolSums-Praktikum\Semester4\PemrogramanBerbasisObjek\14.03.17\2\MLingkaran.java:11: error: cannot find symbol lingkaran l = new lingkaran(); ^ symbol: class lingkaran location: class mLingkaran F:\SchoolSums-Praktikum\Semester4\PemrogramanBerbasisObjek\14.03.17\2\MLingkaran.java:11: error: cannot find symbol lingkaran l = new lingkaran(); ^ symbol: class lingkaran location: class mLingkaran 2 errors
The following are the source code:
Lingkaran.java:
class lingkaran {
private double jari;
private double luas;
private double keliling;
private double phi;
public lingkaran(){
this.phi = 3.14;
this.jari = 10;
this.keliling = this.jari*2*this.phi;
this.luas = this.phi * this.jari * this.jari ;
}
public double getLuas() {
return this.luas;
}
public double getKeliling() {
return this.keliling;
}
}
and the MLingkaran.java:
class mLingkaran {
public static void main (String [] args) {
lingkaran l = new lingkaran();
System.out.println("keliling = " +l.getLuas());
System.out.println("luas = " +l.getKeliling());
}
}