Java构造函数未定义? [英] Java Constructor undefined?

查看:750
本文介绍了Java构造函数未定义?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好吧,我正在为学校做作业,我设置了我的主要类以及另一个名为Transaction的类。在我的主类中有:

Ok, I am working on an assignment for school, and I set up my main class and also another class called Transaction. In my main class I have:

Transaction t = new Transaction();

并且Transaction标有下划线:它说构造函数未定义。 WHY?!

And Transaction is underlined: it says that the constructor undefined. WHY?!

事务类如下所示:

public class Transaction {

private String customerNumber, fName, lName, custAddress, custCity;
private int custZip, custPhone;

/** Constructor*/
public Transaction(String a, String b, String c, String d, String e, int f, int g){
    this.customerNumber = a;
this.fName = b;
this.lName =c;
this.custAddress = d;
this.custCity = e;

}

看起来它应该只是工作, 。即使我把一堆变量插入到我在main中创建新的事务对象,它仍然说未定义。有人请帮助!

It looks like it should just work, but it's just not. Even when I plug in a bunch of variables into where I make the new Transaction object in main, it still says undefined. Somebody please help!

推荐答案

您的类中没有默认构造函数定义。

There is no default constructor definition in your class.

当您提供至少一个参数化构造函数的定义时,编译器不再为您提供默认构造函数。

When you provide the definition of at least one parameterized constructor the compiler no longer provides you the default constructor.

这篇关于Java构造函数未定义?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆