constructor not accepting my information

前端 未结 5 1854
长发绾君心
长发绾君心 2021-01-28 08:32

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

    Person num1, num2, num3;
    num1=new Person(Allison, 6600 Crescent Ave, 32, 902         


        
5条回答
  •  南方客
    南方客 (楼主)
    2021-01-28 09:18

    Step 1:

    First you can check your Person class object is created.

    Print some message in

     public Person() {
          System.out.println("in default constructor");
     }
    

    if you can not see any print statement then problem with object.

    Step 2:

    Check what you pass and passed value is print or not.

    If not print then problem with your parameter(argument).

    Your Problem:

    You are not passing actual string value,You have to pass string value wihin ""

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

    Many SO user give actually answer but this stuff is for feature reader so user can see and don't take mistake next time.

提交回复
热议问题