import java.io.*;
import java.util.*;
public class CompanyDetail {
int Id;
String name;
String department;
static String companyname="Maruti Suzuki";
CompanyDetail(int ID,String Name,String Dept) {
Id=ID;
name=Name;
department=Dept;
}
public void getdata() {
try {
InputStreamReader in = new InputStreamReader(System.in);
BufferedReader br = new BufferedReader(in);
System.out.println("Employee Id :");
Id = Integer.parseInt(br.readLine());
System.out.println("Employee name :");
name= br.readLine();
System.out.println("Employee Department :");
department=br.readLine();
System.out.println("Company is :"+companyname);
}
catch(Exception e) {
}
}
public void printdata() {
System.out.println("Employee Id is :"+Id);
System.out.println("Employee Name is :"+name);
System.out.println("Employee Department is :"+department);
System.out.println("Company is :"+companyname);
}
}
public class CompanyUse {
public static void main(String[] args) {
CompanyDetail cd = new CompanyDetail(int Id,String name,String department);
cd.getdata();
cd.printdata();
}
}
当我创建一个对象时,我在一个主块中遇到错误..eclips 一直告诉我构造函数 CompanyDetail() 是未定义的....没有构造函数它在我的输出中给了我一个空值..请帮助我..i我刚开始学习java...提前非常感谢你:)