构造函数不接受我的信息 [英] constructor not accepting my information

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

问题描述

所以,constuctor是说)期望,错误不是一个语句和;预期

so the constuctor is saying ) expected, error not a statement and ; expected

    Person num1, num2, num3;
    num1=new Person(Allison, 6600 Crescent Ave, 32, 9024231421);
    num2=new Person(George, 5251 Lakewood St, 24, 9024489216);
    num3=new Person(Michael, 2429 Inglis St, 56, 9024212345);

对象类

   public Person() {
   }
//constructor allows programmer to define variable values in demo class
   public Person(String nm, String adr, int ag, long phn) {
    name=nm;
    address=adr;
    age=ag;
    phoneNumber=phn;
 }


推荐答案

num1=new Person(Allison, 6600 Crescent Ave, 32, 9024231421);

应为

num1=new Person("Allison", "6600 Crescent Ave", 32, 9024231421);

String,String,int和long在构造函数中按此顺序排列, code> public Person(String nm,String adr,int ag,long phn)。

String, String, int and long are expected in this order by your constructor, which is defined by public Person(String nm, String adr, int ag, long phn).

Allison不是字符串。

Allison without (double)quotes is not a String.

这篇关于构造函数不接受我的信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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