Question:
java : duplicate class error?
Crow
2013-11-16 08:23:18 UTC
I got an assignment to create package in java, but i got the duplicate error

here is the class :

package crow;

public class absclass extends tabungan
{
public absclass(int x,double y, String z)
{
this.acct_no=x;
this.acct_bil=y;
this.nama=z;
}

public void deposit(double amt)
{
acct_bil += amt;
}

public void withdraw(double amt)
{
if( amt <=0 || amt > acct_bil )
{
System.out.println("jumlah yang anda masukkan salah");
}
else
{
acct_bil -= amt;
}
}

}

-----------------------------------------------------------------------------------------------

package crow;

public class deposito extends tabungan
{
public int durasi;

public deposito(int a,double b,String c,int d)
{
this.acct_no=a;
this.acct_bil=b;
this.nama=c;
this.durasi=d;
}

public void deposit(double amt)
{
acct_bil += amt;
}

public void withdraw(double amt)
{
if( amt <=0 || amt > acct_bil )
{
System.out.println("jumlah yang anda masukkan salah");
}
else
{
acct_bil -= amt;
}
}


}

---------------------------------------------------------------------------------------------------------------------

package crow;

public abstract class tabungan
{
public int acct_no;
public double acct_bil;
public String nama;

public abstract void deposit(double amt);

public abstract void withdraw(double amt);

}

the main class is rather long so i put it in pastebin here http://pastebin.com/dnECMWLS

is this error in main code ?
Four answers:
Puter_Notgeek
2013-11-16 16:09:08 UTC
Wow, long main :-)



Usually duplicate class: someClass

bad class file: someClass.java

file does not contain class somePackage.someClass

Please remove or make sure it appears in the correct subdirectory of the classpath.



This error will occur if you leave the package name out of the top line of the .java file. It can also occur if you have two classes with the same name and package.



With your main.

You should break down the if's to methods (or switch). So much neater and you may find many do the same thing, so that would be a method.



As for the package, maybe write the name package crow like the other classes have.



Good Luck.
2016-10-14 02:51:51 UTC
Java Duplicate Class
brilliant_moves
2013-11-16 10:10:07 UTC
Your main() code is far too long and unreadable. Rembember:

any code that can be repeated, or otherwise belongs in a separate mehod, put it in a separate method.

Also, I don't speak your language, only English, so comments in English would be appreciated.
2016-03-18 10:58:29 UTC
You have both a parameter and a local variable called amountOwed.


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...