This is a question about the arrangement of Java structures

Asked 2 weeks ago, Updated 2 weeks ago, 0 views

public class JAVA2_12 {

 public static void main(String[] args)
{
    Person person[] = new Person[4];
    person[0] = ("Hong Gil-dong", 2000, 4000);
}

class Person
{
    public String name;
    public int date;
    public int salary;
    Person(String name, int date, int salary)
    {
        this.name = name;
        this.date = date;
        this.salary = salary;
 }
}

}

The coding was done to use the structure array, but when running, Syntax error on token "=", Name expected after this token appears I wonder what the reason is

java

2022-09-20 10:59

1 Answers

public class Person{
    public String name;
    public int date;
    public int salary;
    Person(String name, int date, int salary){
        this.name = name;
        this.date = date;
        this.salary = salary;
 }
    public static void main(String[] args){
    Person person[] = new Person[4];
    person[0] = new Person ("Hong Gil-dong", 2000, 4000);
    }
}


2022-09-20 10:59

If you have any answers or tips


© 2022 pinfo. All rights reserved.