import java.util.*;
interface Payable {
public void getAmount(int x);
}
class HEmployee implements Payable {
public void getAmount(int x) {
System.out.println("Amount paid to Hourly employee is Rs.::" + (x * 120));
}
}
class WEmployee implements Payable {
public void getAmount(int x) {
System.out.println("Amount paid to Weakly employee is Rs.::" + (x * 820));
}
}
class J40 {
public static void main(String args[]) {
Scanner s = new Scanner(System.in);
Payable refer;
HEmployee h1 = new HEmployee();
System.out.println("Enter the Hourly employee worked Hours::");
int h = s.nextInt();
refer = h1;
refer.getAmount(h);
WEmployee w1 = new WEmployee();
System.out.println("Enter Weakly employee worked Hours::");
int w = s.nextInt();
refer = w1;
refer.getAmount(w);
}
}
成功與運行中的異常日食,但在命令提示符下拋出異常。類:在Eclipse中成功運行,但在罰球命令提示符
的名字J40.java
javac J40.java
成功保存。
java J40
拋出異常
請重新格式化您的問題,並請出示您的異常 –
您遇到的錯誤是什麼? –
它引發了什麼異常? –