Q:

working with objects in java, after creating new object cant reach him from main

in the main I wrote those two statement:
Account newAccount = new Account(name);
newAccount.addNewProduct();

this is the constructor code and attribute in Account:
private final int MAX_PRODUCTS = 50; //Assumes no more than 50 products per customer
private String name;        //Name of the customer
private int sum;            //Sum amount of the purchase
private Product[] productList;      //List of products for a customer 
private int productCounter;         //Counter for number of products

public Account(String name)
{
    Product[] productList = new Product[MAX_PRODUCTS]; //New empty list of products of the customer }
    productCounter = 0;
    sum = 0;
    name = name;
}

I cant figure why, but in this method:
public void addNewProduct()
{   
    System.out.println("Name is: " + this.name);
    productList[productCounter] = new Product();
    productCounter++;
} 

its prints the name as null although i entered a name in the console...
Its like not saving the attributes of the object newAccount I created. why?

A:

name = name will not work. You need to use this.name = name
This is because when you use name you refer to the parameter in the constructor; when you use this.name you refer to the field.

