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.
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.
Update your setName
method -
public void setName(String productName){
this.name = productName;
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.