我正在 cmd 中编译我所有的 java 程序,但是当我在程序下面运行时,它显示了一个错误,比如"reached end of file while parsing"
!当我尝试在 Eclipse 中运行它时,它在粗体代码下方显示红色下划线,即方法和主要方法。
import java.io.*;
class empl{
int empno;
String name;
String position;
int ph;
public void getdata()throws IOException{
DataInputStream e = new DataInputStream(System.in);
System.out.println("Enter name: ");
empno = Integer.parseInt(e.readLine());
System.out.println("Enter your name: ");
name = e.readLine();
System.out.println("Enter the employee position: ");
position=e.readLine();
System.out.println("Enter the phone number: ");
ph = Integer.parseInt(e.readLine());
}
public void displaydata() {
System.out.println(empno+"\t"+name+"\t"+position+"\t"+ph);
}
class manager extends empl{
int salary;
String secname;
public void getdata() throws IOException{
getdata();
DataInputStream e= new DataInputStream(System.in);
System.out.println("Enter salary: ");
salary=Integer.parseInt(e.readLine());
System.out.println("Enter second name: ");
secname= e.readLine();
}
public void displaydata(){
displaydata();
System.out.println(salary+"\t"+secname);
}
class inheritt{
public static void **main(String []args)throws IOException**{
inheritt e1= new inheritt();
inheritt e2= new inheritt();
**e1.getdata();
e2.getdata();
e1.displaydata();
e2.displaydata();**
}