不正确发送/接收数据java

时间:2022-06-18 07:34:17

Currently I am trying to create an array of objects and pass in its name through string that I split. But for some reason its not sending the data correctly.

目前我正在尝试创建一个对象数组,并通过我拆分的字符串传递其名称。但由于某种原因,它没有正确发送数据。

data = reader.readLine().split("(?<=\\d)\\s+|\\s+at\\s+");
        Products[i] = new Product();
        Products[i].setName(data[1]);

This is the get and set methods for the other class.

这是其他类的get和set方法。

public void setName(String productName){

    productName = this.name;

}
public String getName()
{
    return this.name;
}

All name is, is a private string. Any help and explanation would be greatly appreciated.

所有名称都是私有字符串。任何帮助和解释将不胜感激。

1 个解决方案

#1


3  

Update your setName method -

更新你的setName方法 -

public void setName(String productName){
    this.name = productName;
}

#1


3  

Update your setName method -

更新你的setName方法 -

public void setName(String productName){
    this.name = productName;
}