【发布时间】:2015-01-19 03:37:45
【问题描述】:
我创建了两个类应用程序,类是 1. InVoice 2. InVoiceTest,我正在将 InVoice 类导入 InVoiceTest,这里是 InVoice 类
public class InVoice
{
private String name;
private String description;
private int quantity;
private double price;
public InVoice (String n, String d, int q, double p)
{
name=n;
description=d;
quantity=q;
price=p;
}
public void set (String n, String d, int q, double p)
{
name=n;
description=d;
quantity=q;
price=p;
}
public String getname()
{
return name;
}
public String getdescription()
{
return description;
}
public int getquantity()
{
return quantity;
}
public double getprice()
{
return price;
}
}
这是 InVoiceTest 类
import java.util.Scanner;
public class InVoiceTest
{
public static void main (String [] aa)
{
InVoice object=new InVoice();
Scanner obj=new Scanner (System.in);
System.out.print("Enter Item name: ");
String name=obj.nextLine();
System.out.print("\nEnter Item description: ");
String description=obj.nextLine();
System.out.print("\nEnter quantity: ");
int quantity=obj.nextInt();
System.out.print("\nEnter price: ");
double price=obj.nextDouble();
object.set(name,description, quantity, price);
}
}
这两个类在同一个目录中,我通过命令提示符编译它们,并且这个错误一次又一次地显示
InVoiceTest.class can not find symbol
symbol: constructor InVoice()
location: class InVoice
InVoice object=new InVoice();
【问题讨论】:
-
InVoice没有默认构造函数 (InVoice()) -
这和C++有什么关系?
标签: java compiler-errors