I am trying to assign the values to the array products[] using the array arr[] which is passed in the constructor. When I compile the code I get the error
Shop.java:10: error: not a statement
products[]=arr.clone();
^ Shop.java:10: error: ';' expected
products[]=arr.clone();
How can I resolve the error and assign the arr[] values to the products[]
import java.util.Scanner;
public class Shop{
private String shopName;
private String shopAddress;
private String products[];
public Shop(String name,String add, String[] arr){
shopName=name;
shopAddress=add;
products[]=arr.clone();
}
}
I haven't given all the code, but assume
arr[]={"apple","orange","mango","banana"}